|
Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
#include <seqlock.h>
Public Member Functions | |
| Seqlock (T value) | |
| Initialize with given value. | |
| seqlock_version_t | version () const |
| Load value version. Wait-free. | |
| bool | try_store (const T &value) |
| Store value. Can be called concurrently, but only one concurrent call will succeed. Is both lock-free and wait-free, i.e. it never waits for sleeping threads and never spins. After this call returns, any thread calling wait_load() is guaranteed to get the updated value, and try_load() is guaranteed either return the updated value or fail (if changes are not fully published yet). | |
| bool | try_store_v (const T &value, seqlock_version_t &ver) |
| Store value. Like try_store(), but also returns updated version. | |
| void | exclusive_store (const T &value) |
| Store value. Can NOT be called concurrently, assumes that writes are serialized. Is both lock-free and wait-free, i.e. it never waits for sleeping threads and never spins. After this call returns, any thread calling wait_load() is guaranteed to get the updated value, and try_load() is guaranteed either return the updated value or fail (if changes are not fully published yet). | |
| void | exclusive_store_v (const T &value, seqlock_version_t &ver) |
| Store value. Like exclusive_store(), but also returns updated version. | |
| bool | try_load (T &value) const |
| Try to load value. Returns true if the value was loaded. May return false if concurrent store is currently in progress. Is both lock-free and wait-free, i.e. it never waits for sleeping threads and never spins. | |
| bool | try_load_v (T &value, seqlock_version_t &ver) const |
| Try to load value and version. Like try_load(), but also returns version. | |
| T | wait_load () const |
| Load value. May spin until concurrent store completes. Is NOT lock-free (or wait-free). | |
| void | wait_load_v (T &value, seqlock_version_t &ver) const |
| Load value and version. Like wait_load(), but also returns version. | |
Provides safe concurrent access to a single value. Provides sequential consistency. Optimized for infrequent writes and frequent reads. Writes are lock-free and take priority over reads.
See details on the barriers here: https://elixir.bootlin.com/linux/latest/source/include/linux/seqlock.h https://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf
|
inlineexplicit |
|
inline |
Store value. Can NOT be called concurrently, assumes that writes are serialized. Is both lock-free and wait-free, i.e. it never waits for sleeping threads and never spins. After this call returns, any thread calling wait_load() is guaranteed to get the updated value, and try_load() is guaranteed either return the updated value or fail (if changes are not fully published yet).
|
inline |
Store value. Like exclusive_store(), but also returns updated version.
|
inline |
|
inline |
Try to load value and version. Like try_load(), but also returns version.
|
inline |
Store value. Can be called concurrently, but only one concurrent call will succeed. Is both lock-free and wait-free, i.e. it never waits for sleeping threads and never spins. After this call returns, any thread calling wait_load() is guaranteed to get the updated value, and try_load() is guaranteed either return the updated value or fail (if changes are not fully published yet).
|
inline |
Store value. Like try_store(), but also returns updated version.
|
inline |
|
inline |
|
inline |
Load value and version. Like wait_load(), but also returns version.