MySQL 9.1.0
Source Code Documentation
|
A class that allows to read value of variable of some type T atomically and allows the value to be changed, all using lock-free operations. More...
#include <ut0seq_lock.h>
Public Member Functions | |
Seq_lock ()=default | |
template<typename... Args> | |
Seq_lock (Args... args) | |
template<typename Op > | |
void | write (Op &&op) |
Writes a new value for the variable of type T. More... | |
template<typename Op > | |
auto | read (Op &&op) const |
Private Attributes | |
T | m_value |
Stored value. More... | |
std::atomic< uint64_t > | m_seq {0} |
Sequence count. More... | |
Additional Inherited Members | |
Private Member Functions inherited from ut::Non_copyable | |
Non_copyable (const Non_copyable &)=delete | |
Non_copyable & | operator= (const Non_copyable &)=delete |
Non_copyable ()=default | |
~Non_copyable ()=default | |
A class that allows to read value of variable of some type T atomically and allows the value to be changed, all using lock-free operations.
The type T has to be composed of std::atomic fields only. That is because read(op_r) might read it in parallel to write(op_w). Other than that you are allowed to use any type. Inspired by https://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf Figure 6.
|
default |
Writes a new value for the variable of type T.
The op can use memory_order_relaxed stores. NOTE: The user needs to synchronize all calls to this method.
|
private |
Sequence count.
Even when the value is ready for read, odd when the value is being written to.
|
private |
Stored value.