Seqlock.
More...
#include <seqlock.h>
|
| Seqlock (T value) |
| Initialize with given value. More...
|
|
seqlock_version_t | version () const |
| Load value version. Wait-free. More...
|
|
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). More...
|
|
bool | try_store_v (const T &value, seqlock_version_t &ver) |
| Store value. Like try_store(), but also returns updated version. More...
|
|
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). More...
|
|
void | exclusive_store_v (const T &value, seqlock_version_t &ver) |
| Store value. Like exclusive_store(), but also returns updated version. More...
|
|
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. More...
|
|
bool | try_load_v (T &value, seqlock_version_t &ver) const |
| Try to load value and version. Like try_load(), but also returns version. More...
|
|
T | wait_load () const |
| Load value. May spin until concurrent store completes. Is NOT lock-free (or wait-free). More...
|
|
void | wait_load_v (T &value, seqlock_version_t &ver) const |
| Load value and version. Like wait_load(), but also returns version. More...
|
|
template<class T>
class roc::core::Seqlock< T >
Seqlock.
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
Definition at line 31 of file seqlock.h.
◆ Seqlock()
Initialize with given value.
Definition at line 34 of file seqlock.h.
◆ exclusive_store()
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).
Definition at line 69 of file seqlock.h.
◆ exclusive_store_v()
◆ try_load()
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.
Definition at line 85 of file seqlock.h.
◆ try_load_v()
Try to load value and version. Like try_load(), but also returns version.
Definition at line 92 of file seqlock.h.
◆ try_store()
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).
Definition at line 51 of file seqlock.h.
◆ try_store_v()
◆ version()
Load value version. Wait-free.
Definition at line 40 of file seqlock.h.
◆ wait_load()
Load value. May spin until concurrent store completes. Is NOT lock-free (or wait-free).
Definition at line 99 of file seqlock.h.
◆ wait_load_v()
The documentation for this class was generated from the following file: