24#include <condition_variable>
43 :
public ICallFutureImpl,
44 public std::enable_shared_from_this<CallFutureImpl> {
65 result_.emplace(std::move(result));
83 if (error.
code() == StatusCode::SUCCESS) {
85 StatusCode::INVALID_ARGUMENT,
"Invalid error status.");
102 std::chrono::nanoseconds timeout)
override {
119 const auto deadline = std::min<std::chrono::steady_clock::time_point>(
120 std::chrono::steady_clock::now() + timeout,
deadline_);
133 lock, deadline, [
this] { return is_set_; })) {
135 "Result of an RPC couldn't be received within a timeout.");
152 std::optional<messages::CallResult>
result_{};
Definition of CallResult class.
messages::CallResult get_result_within(std::chrono::nanoseconds timeout) override
Get the result of RPC within a timeout.
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.
void wait()
Wait the result.
std::chrono::steady_clock::time_point deadline_
Deadline of the result of the RPC.
messages::CallResult get_result() override
Get the result of RPC.
void wait_for(std::chrono::nanoseconds timeout)
Wait the result for the given time.
CallFutureImpl(std::chrono::steady_clock::time_point deadline)
Constructor.
void set(messages::CallResult result)
Set a result.
std::mutex is_set_mutex_
Mutex of is_set_.
bool is_set_
Whether a result or an error is set.
std::optional< messages::CallResult > result_
Result of the RPC.
messages::CallResult get_result_impl()
Get the result assuming the result is already set.
std::condition_variable is_set_cond_var_
Condition variable for notifying change of is_set_.
void set(const Status &error)
Set an error.
Class of exceptions in cpp-msgpack-rpc library.
StatusCode code() const noexcept
Get the status code.
Class of results of methods.
Definition of ICallFutureImpl class.
Definition of MsgpackRPCException class.
Namespace of internal implementations.
Definition of Status class.
Definition of StatusCode enumeration.