cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::clients::impl::CallFutureImpl Class Referencefinal

Class of internal implementation of future objects to get results of RPCs asynchronously. More...

#include <msgpack_rpc/clients/impl/call_future_impl.h>

Inheritance diagram for msgpack_rpc::clients::impl::CallFutureImpl:
Collaboration diagram for msgpack_rpc::clients::impl::CallFutureImpl:

Public Member Functions

 CallFutureImpl (std::chrono::steady_clock::time_point deadline)
 Constructor.
messages::CallResult get_result () override
 Get the result of RPC.
messages::CallResult get_result_within (std::chrono::nanoseconds timeout) override
 Get the result of RPC within a timeout.
void set (const Status &error)
 Set an error.
void set (messages::CallResult result)
 Set a result.
Public Member Functions inherited from msgpack_rpc::clients::impl::ICallFutureImpl
 ICallFutureImpl (const ICallFutureImpl &)=delete
 ICallFutureImpl (ICallFutureImpl &&)=delete
virtual ~ICallFutureImpl () noexcept=default
 Destructor.
ICallFutureImploperator= (const ICallFutureImpl &)=delete
ICallFutureImploperator= (ICallFutureImpl &&)=delete

Private Member Functions

messages::CallResult get_result_impl ()
 Get the result assuming the result is already set.
void wait ()
 Wait the result.
void wait_for (std::chrono::nanoseconds timeout)
 Wait the result for the given time.
void wait_until_impl (std::chrono::steady_clock::time_point deadline)
 Wait the result until the given deadline without consideration of the deadline of the RPC.

Private Attributes

std::chrono::steady_clock::time_point deadline_
 Deadline of the result of the RPC.
bool is_set_ {false}
 Whether a result or an error is set.
std::condition_variable is_set_cond_var_ {}
 Condition variable for notifying change of is_set_.
std::mutex is_set_mutex_ {}
 Mutex of is_set_.
std::optional< messages::CallResultresult_ {}
 Result of the RPC.
Status status_ {}
 Status.

Additional Inherited Members

Protected Member Functions inherited from msgpack_rpc::clients::impl::ICallFutureImpl
 ICallFutureImpl () noexcept=default
 Constructor.

Detailed Description

Class of internal implementation of future objects to get results of RPCs asynchronously.

Definition at line 42 of file call_future_impl.h.

Constructor & Destructor Documentation

◆ CallFutureImpl()

msgpack_rpc::clients::impl::CallFutureImpl::CallFutureImpl ( std::chrono::steady_clock::time_point deadline)
inlineexplicit

Constructor.

Parameters
[in]deadlineDeadline of the result of the RPC.

Definition at line 51 of file call_future_impl.h.

Member Function Documentation

◆ get_result()

messages::CallResult msgpack_rpc::clients::impl::CallFutureImpl::get_result ( )
inlinenodiscardoverridevirtual

Get the result of RPC.

Returns
Result.
Note
This function will wait for the result if not received.

Implements msgpack_rpc::clients::impl::ICallFutureImpl.

Definition at line 95 of file call_future_impl.h.

◆ get_result_impl()

messages::CallResult msgpack_rpc::clients::impl::CallFutureImpl::get_result_impl ( )
inlinenodiscardprivate

Get the result assuming the result is already set.

Returns
Result.

Definition at line 144 of file call_future_impl.h.

◆ get_result_within()

messages::CallResult msgpack_rpc::clients::impl::CallFutureImpl::get_result_within ( std::chrono::nanoseconds timeout)
inlinenodiscardoverridevirtual

Get the result of RPC within a timeout.

Parameters
[in]timeoutTimeout.
Returns
Result.
Note
This function will wait for the result if not received, and throw an exception when no result can be received within the given timeout.

Implements msgpack_rpc::clients::impl::ICallFutureImpl.

Definition at line 101 of file call_future_impl.h.

◆ set() [1/2]

void msgpack_rpc::clients::impl::CallFutureImpl::set ( const Status & error)
inline

Set an error.

Parameters
[in]errorError.

Definition at line 77 of file call_future_impl.h.

◆ set() [2/2]

void msgpack_rpc::clients::impl::CallFutureImpl::set ( messages::CallResult result)
inline

Set a result.

Parameters
[in]resultResult.

Definition at line 59 of file call_future_impl.h.

◆ wait()

void msgpack_rpc::clients::impl::CallFutureImpl::wait ( )
inlineprivate

Wait the result.

Definition at line 111 of file call_future_impl.h.

◆ wait_for()

void msgpack_rpc::clients::impl::CallFutureImpl::wait_for ( std::chrono::nanoseconds timeout)
inlineprivate

Wait the result for the given time.

Parameters
[in]timeoutDuration of timeout of waiting.

Definition at line 118 of file call_future_impl.h.

◆ wait_until_impl()

void msgpack_rpc::clients::impl::CallFutureImpl::wait_until_impl ( std::chrono::steady_clock::time_point deadline)
inlineprivate

Wait the result until the given deadline without consideration of the deadline of the RPC.

Parameters
[in]deadlineDeadline of waiting.

Definition at line 130 of file call_future_impl.h.

Member Data Documentation

◆ deadline_

std::chrono::steady_clock::time_point msgpack_rpc::clients::impl::CallFutureImpl::deadline_
private

Deadline of the result of the RPC.

Definition at line 161 of file call_future_impl.h.

◆ is_set_

bool msgpack_rpc::clients::impl::CallFutureImpl::is_set_ {false}
private

Whether a result or an error is set.

Definition at line 158 of file call_future_impl.h.

◆ is_set_cond_var_

std::condition_variable msgpack_rpc::clients::impl::CallFutureImpl::is_set_cond_var_ {}
private

Condition variable for notifying change of is_set_.

Definition at line 173 of file call_future_impl.h.

◆ is_set_mutex_

std::mutex msgpack_rpc::clients::impl::CallFutureImpl::is_set_mutex_ {}
private

Mutex of is_set_.

  • This mutex should be locked for use of is_set_.
  • If is_set_ is set to true, result_ and status_ can be used without locks.

Definition at line 170 of file call_future_impl.h.

◆ result_

std::optional<messages::CallResult> msgpack_rpc::clients::impl::CallFutureImpl::result_ {}
private

Result of the RPC.

Definition at line 152 of file call_future_impl.h.

◆ status_

Status msgpack_rpc::clients::impl::CallFutureImpl::status_ {}
private

Status.

Definition at line 155 of file call_future_impl.h.


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