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 290 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 303 of file rcu.hpp.

◆ ~WritablePtr()

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

Definition at line 306 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 315 of file rcu.hpp.

◆ Get() [1/2]

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

Definition at line 321 of file rcu.hpp.

◆ Get() [2/2]

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

Definition at line 326 of file rcu.hpp.

◆ operator*() [1/2]

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

Definition at line 331 of file rcu.hpp.

◆ operator*() [2/2]

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

Definition at line 332 of file rcu.hpp.

◆ operator->() [1/2]

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

Definition at line 328 of file rcu.hpp.

◆ operator->() [2/2]

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

Definition at line 329 of file rcu.hpp.


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