xenium
|
Generic implementation of the LeftRight algorithm proposed by Ramalhete and Correia [RC15]. More...
#include <left_right.hpp>
Public Member Functions | |
left_right (T source) | |
Initialize the two underlying T instances with the specified source . | |
left_right (T left, T right) | |
Initializes the two underlying instances withe the specified sources. | |
left_right ()=default | |
Default constructs both underlying instances. | |
template<typename Func > | |
auto | read (Func &&func) const |
Performs a read operation on the active instance using the specified functor. | |
template<typename Func > | |
void | update (Func &&func) |
Performs an update operation on both underlying instances using the specified functor. | |
Generic implementation of the LeftRight algorithm proposed by Ramalhete and Correia [RC15].
The LeftRight algorithm provides the following advantages when compared to a read-write-lock:
This is comes at the cost of a duplication of the underlying data structure, which also means that update operations have to be applied to both instances.
T |
|
inline |
Initialize the two underlying T instances with the specified source
.
The first instance is copy-constructed while the second one is move-constructed.
source | the source used to initialize the two underlying instances. |
Initializes the two underlying instances withe the specified sources.
Both instances are move-constructed from the specified sources.
left | the source to initialize the left instance |
right | the source to initialize the right instance |
|
inline |
Performs a read operation on the active instance using the specified functor.
The functor func
is called for the currently active instance. The instance is passed to the functor as a const reference.
This method simply returns the result of the call to func
, i.e., the return type of this method corresponds to the return type of the func
;
Func |
func |
func
|
inline |
Performs an update operation on both underlying instances using the specified functor.
The functor func
is called twice - once for each underlying instance. The instance to be updated is passed as a non-const reference to func
.
Func |
func |