commit | 0ee2c2d99502f0a552d9b2ee98f1f97fed196d48 | [log] [tgz] |
---|---|---|
author | Prashant Varanasi <github@prashantv.com> | Tue Nov 14 10:36:59 2017 -0800 |
committer | GitHub <noreply@github.com> | Tue Nov 14 10:36:59 2017 -0800 |
tree | 0a701aa11202f5db05c4b8278d7c8f7cc725403d | |
parent | e81582a97d2dffa59c4cce87d076b4e372aeb62e [diff] |
Concurrently modify same atomic in stress tests (#33) Currently, the stress tests start multiple goroutines, but they all have their own local atomic, so they are not concurrently modifying the same values. Return a function which can be run concurrently to modify the same atomic.
Simple wrappers for primitive types to enforce atomic access.
go get -u go.uber.org/atomic
The standard library‘s sync/atomic
is powerful, but it’s easy to forget which variables must be accessed atomically. go.uber.org/atomic
preserves all the functionality of the standard library, but wraps the primitive types to provide a safer, more convenient API.
var atom atomic.Uint32
atom.Store(42)
atom.Sub(2)
atom.CAS(40, 11)
See the documentation for a complete API specification.
Stable.