userver: utils::SwappingSmart< T > Class Template Reference
Loading...
Searching...
No Matches
utils::SwappingSmart< T > Class Template Reference

#include <userver/utils/swappingsmart.hpp>

Detailed Description

template<typename T>
class utils::SwappingSmart< T >

Deprecated RCU-like shared_ptr cell with swap-based updates for readers.

Use a faster and more reliable rcu::Variable instead of this class!

This class helps to store pointer. Pointer stored as shared_ptr. Whet you call Get, you will get copy of this shared pointer under read lock. When you call Set pointer, it will be stored under writelock.

It works slower than SwappingPtr in 5 times, but readers will always have shared_ptr that they obtained, so it is impossible that data will be free'd.

Definition at line 25 of file swappingsmart.hpp.

Public Member Functions

 SwappingSmart (const std::shared_ptr< T > &ptr)
 
std::shared_ptr< T > Get () const
 
void Set (const std::shared_ptr< T > &ptr)
 
void Set (T &&obj)
 
void Clear ()
 

Constructor & Destructor Documentation

◆ SwappingSmart()

template<typename T>
utils::SwappingSmart< T >::SwappingSmart ( const std::shared_ptr< T > & ptr)
inlineexplicit

Definition at line 29 of file swappingsmart.hpp.

Member Function Documentation

◆ Clear()

template<typename T>
void utils::SwappingSmart< T >::Clear ( )
inline

Definition at line 53 of file swappingsmart.hpp.

◆ Get()

template<typename T>
std::shared_ptr< T > utils::SwappingSmart< T >::Get ( ) const
inline

Definition at line 31 of file swappingsmart.hpp.

◆ Set() [1/2]

template<typename T>
void utils::SwappingSmart< T >::Set ( const std::shared_ptr< T > & ptr)
inline

Definition at line 35 of file swappingsmart.hpp.

◆ Set() [2/2]

template<typename T>
void utils::SwappingSmart< T >::Set ( T && obj)
inline

Definition at line 52 of file swappingsmart.hpp.


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