#include <userver/utils/lazy_shared_ptr.hpp>
A lazy wrapper around utils::SharedReadablePtr that fetches the data on first access.
Provides standard thread-safety guarantee: const
methods can be called concurrently. Once fetched, the same data is guaranteed to be returned unless the pointer is assigned to.
Definition at line 28 of file lazy_shared_ptr.hpp.
Public Member Functions | |
LazySharedPtr () noexcept | |
The default constructor, initializes with nullptr . | |
LazySharedPtr (utils::SharedReadablePtr< T > ptr) noexcept | |
The non-lazy constructor. | |
LazySharedPtr (std::function< utils::SharedReadablePtr< T >()> function) noexcept | |
The lazy constructor. | |
LazySharedPtr (const LazySharedPtr &other) | |
The copy constructor. | |
LazySharedPtr (LazySharedPtr &&other) noexcept | |
The move constructor. | |
LazySharedPtr & | operator= (const LazySharedPtr &other) |
The copy assignment operator. | |
LazySharedPtr & | operator= (LazySharedPtr &&other) noexcept |
The move assignment operator. | |
const T * | Get () const & |
Get a pointer to the data (may be null). Fetches the data on the first access. | |
const utils::SharedReadablePtr< T > & | GetShared () const & |
Get a smart pointer to the data (may be null). Fetches the data on the first access. | |
const T & | operator* () const & |
const T * | operator-> () const & |
operator bool () const & | |
operator const utils::SharedReadablePtr< T > & () const & | |
operator std::shared_ptr< const T > () const & | |
|
inlinenoexcept |
The default constructor, initializes with nullptr
.
Definition at line 31 of file lazy_shared_ptr.hpp.
|
inlinenoexcept |
The non-lazy constructor.
Definition at line 35 of file lazy_shared_ptr.hpp.
|
inlinenoexcept |
The lazy constructor.
Definition at line 39 of file lazy_shared_ptr.hpp.
|
inline |
The copy constructor.
other
has not been fetched yet, this
will not fetch immediately, so this
and other
may end up pointing to different objects. Definition at line 46 of file lazy_shared_ptr.hpp.
|
inlinenoexcept |
The move constructor.
Definition at line 55 of file lazy_shared_ptr.hpp.
|
inline |
Get a pointer to the data (may be null). Fetches the data on the first access.
Definition at line 80 of file lazy_shared_ptr.hpp.
|
inline |
Get a smart pointer to the data (may be null). Fetches the data on the first access.
Definition at line 95 of file lazy_shared_ptr.hpp.
|
inlineexplicit |
Get() != nullptr
Definition at line 126 of file lazy_shared_ptr.hpp.
|
inline |
GetShared()
Definition at line 129 of file lazy_shared_ptr.hpp.
|
inline |
GetShared()
Definition at line 132 of file lazy_shared_ptr.hpp.
|
inline |
|
inline |
|
inline |
The copy assignment operator.
other
do not generate them. Definition at line 64 of file lazy_shared_ptr.hpp.
|
inlinenoexcept |
The move assignment operator.
Definition at line 70 of file lazy_shared_ptr.hpp.