Seqlock.
More...
#include <seqlock.h>
|
| | 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_ver (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 srialized. 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_ver (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_ver (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_ver (T &value, seqlock_version_t &ver) const |
| | Load value and version. Like wait_load(), but also returns version.
|
| |
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 43 of file seqlock.h.
◆ Seqlock()
Initialize with given value.
Definition at line 46 of file seqlock.h.
◆ exclusive_store()
Store value. Can NOT be called concurrently, assumes that writes are srialized. 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 82 of file seqlock.h.
◆ exclusive_store_ver()
◆ 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 98 of file seqlock.h.
◆ try_load_ver()
Try to load value and version. Like try_load(), but also returns version.
Definition at line 105 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 64 of file seqlock.h.
◆ try_store_ver()
◆ version()
Load value version. Wait-free.
Definition at line 53 of file seqlock.h.
◆ wait_load()
Load value. May spin until concurrent store completes. Is NOT lock-free (or wait-free).
Definition at line 112 of file seqlock.h.
◆ wait_load_ver()
The documentation for this class was generated from the following file: