12 #ifndef ROC_CORE_SEQLOCK_H_
13 #define ROC_CORE_SEQLOCK_H_
53 return impl_.
try_store(ver, &val_,
sizeof(val_), &value);
59 return impl_.
try_store(ver, &val_,
sizeof(val_), &value);
102 impl_.
wait_load(ver, &val_,
sizeof(val_), &value);
109 impl_.
wait_load(ver, &val_,
sizeof(val_), &value);
Base class for non-copyable objects.
Seqlock implementation class.
bool try_store(seqlock_version_t &ver, void *current_value, size_t value_size, const void *new_value)
Try to store value.
void exclusive_store(seqlock_version_t &ver, void *current_value, size_t value_size, const void *new_value)
Store value.
bool try_load_repeat(seqlock_version_t &ver, const void *current_value, size_t value_size, void *return_value) const
Try to load value and version.
void wait_load(seqlock_version_t &ver, const void *current_value, size_t value_size, void *return_value) const
Load value and version.
seqlock_version_t version() const
Load value version.
bool try_store(const T &value)
Store value. Can be called concurrently, but only one concurrent call will succeed....
bool try_load_v(T &value, seqlock_version_t &ver) const
Try to load value and version. Like try_load(), but also returns version.
void exclusive_store(const T &value)
Store value. Can NOT be called concurrently, assumes that writes are serialized. Is both lock-free an...
void exclusive_store_v(const T &value, seqlock_version_t &ver)
Store value. Like exclusive_store(), but also returns updated version.
seqlock_version_t version() const
Load value version. Wait-free.
Seqlock(T value)
Initialize with given value.
bool try_store_v(const T &value, seqlock_version_t &ver)
Store value. Like try_store(), but also returns updated 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.
bool try_load(T &value) const
Try to load value. Returns true if the value was loaded. May return false if concurrent store is curr...
uint32_t seqlock_version_t
Type for holding seqlock value version. Version is changed each value update. May wrap.