cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::util::impl::SharedObjectBuffer< T > Class Template Reference

Class of buffers of shared objects. More...

#include <msgpack_rpc/util/impl/shared_objects.h>

Collaboration diagram for msgpack_rpc::util::impl::SharedObjectBuffer< T >:

Public Member Functions

 SharedObjectBuffer () noexcept=default
 Constructor.
void add_reference () noexcept
 Increase the reference count.
template<typename... Args>
void emplace (Args &&... args)
 Construct an object.
T * get () noexcept
 Access the object.
void release () noexcept
 Decrease the reference count and destruct the object if needed.
bool try_start_use () noexcept
 Try to start to use.

Private Attributes

std::optional< T > buffer_ {}
 Buffer.
std::atomic< int > reference_count_ {-1}
 Reference count. (-1 for unused buffer.)

Detailed Description

template<typename T>
class msgpack_rpc::util::impl::SharedObjectBuffer< T >

Class of buffers of shared objects.

Template Parameters
TType of the shared objects.

Definition at line 37 of file shared_objects.h.

Member Function Documentation

◆ add_reference()

template<typename T>
void msgpack_rpc::util::impl::SharedObjectBuffer< T >::add_reference ( )
inlinenoexcept

Increase the reference count.

Definition at line 73 of file shared_objects.h.

◆ emplace()

template<typename T>
template<typename... Args>
void msgpack_rpc::util::impl::SharedObjectBuffer< T >::emplace ( Args &&... args)
inline

Construct an object.

Warning
This can be called safely only when the reference count is 1.
Template Parameters
ArgsTypes of arguments.
Parameters
[in]argsArguments.

Definition at line 66 of file shared_objects.h.

◆ get()

template<typename T>
T * msgpack_rpc::util::impl::SharedObjectBuffer< T >::get ( )
inlinenodiscardnoexcept

Access the object.

Returns
Pointer to the object.

Definition at line 95 of file shared_objects.h.

◆ release()

template<typename T>
void msgpack_rpc::util::impl::SharedObjectBuffer< T >::release ( )
inlinenoexcept

Decrease the reference count and destruct the object if needed.

Definition at line 80 of file shared_objects.h.

◆ try_start_use()

template<typename T>
bool msgpack_rpc::util::impl::SharedObjectBuffer< T >::try_start_use ( )
inlinenodiscardnoexcept

Try to start to use.

Return values
trueSucceeded.
falseFailed.

Definition at line 50 of file shared_objects.h.

Member Data Documentation

◆ buffer_

template<typename T>
std::optional<T> msgpack_rpc::util::impl::SharedObjectBuffer< T >::buffer_ {}
private

Buffer.

Definition at line 104 of file shared_objects.h.

◆ reference_count_

template<typename T>
std::atomic<int> msgpack_rpc::util::impl::SharedObjectBuffer< T >::reference_count_ {-1}
private

Reference count. (-1 for unused buffer.)

Definition at line 101 of file shared_objects.h.


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