userver: rcu::WritablePtr< T, RcuTraits > Class Template Reference
Loading...
Searching...
No Matches
rcu::WritablePtr< T, RcuTraits > Class Template Reference

#include <userver/rcu/rcu.hpp>

Detailed Description

template<typename T, typename RcuTraits>
class rcu::WritablePtr< T, RcuTraits >

Smart pointer for rcu::Variable<T> for changing RCU value. It stores a reference to a to-be-changed value and allows one to mutate the value (e.g. add items to std::unordered_map). Changed value is not visible to readers until explicit store by Commit. Only a single writer may own a WritablePtr associated with the same Variable, so WritablePtr creates a critical section. This critical section doesn't affect readers, so a slow writer doesn't block readers.

Note
you may not pass WritablePtr between coroutines as it owns engine::Mutex, which must be unlocked in the same coroutine that was used to lock the mutex.

Definition at line 193 of file rcu.hpp.

Public Member Functions

 WritablePtr (WritablePtr &&other) noexcept
 
void Commit ()
 
T * Get () &
 
T * Get () &&
 
T * operator-> () &
 
T * operator-> () &&
 
T & operator* () &
 
T & operator* () &&
 

Constructor & Destructor Documentation

◆ WritablePtr()

template<typename T , typename RcuTraits >
rcu::WritablePtr< T, RcuTraits >::WritablePtr ( WritablePtr< T, RcuTraits > && other)
inlinenoexcept

Definition at line 212 of file rcu.hpp.

◆ ~WritablePtr()

template<typename T , typename RcuTraits >
rcu::WritablePtr< T, RcuTraits >::~WritablePtr ( )
inline

Definition at line 217 of file rcu.hpp.

Member Function Documentation

◆ Commit()

template<typename T , typename RcuTraits >
void rcu::WritablePtr< T, RcuTraits >::Commit ( )
inline

Store the changed value in Variable. After Commit() the value becomes visible to new readers (IOW, Variable::Read() returns ReadablePtr referencing the stored value, not an old value).

Definition at line 227 of file rcu.hpp.

◆ Get() [1/2]

template<typename T , typename RcuTraits >
T * rcu::WritablePtr< T, RcuTraits >::Get ( ) &
inline

Definition at line 233 of file rcu.hpp.

◆ Get() [2/2]

template<typename T , typename RcuTraits >
T * rcu::WritablePtr< T, RcuTraits >::Get ( ) &&
inline

Definition at line 238 of file rcu.hpp.

◆ operator*() [1/2]

template<typename T , typename RcuTraits >
T & rcu::WritablePtr< T, RcuTraits >::operator* ( ) &
inline

Definition at line 243 of file rcu.hpp.

◆ operator*() [2/2]

template<typename T , typename RcuTraits >
T & rcu::WritablePtr< T, RcuTraits >::operator* ( ) &&
inline

Definition at line 244 of file rcu.hpp.

◆ operator->() [1/2]

template<typename T , typename RcuTraits >
T * rcu::WritablePtr< T, RcuTraits >::operator-> ( ) &
inline

Definition at line 240 of file rcu.hpp.

◆ operator->() [2/2]

template<typename T , typename RcuTraits >
T * rcu::WritablePtr< T, RcuTraits >::operator-> ( ) &&
inline

Definition at line 241 of file rcu.hpp.


The documentation for this class was generated from the following files: