cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
call_promise.h.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include <chrono>
23
#include <memory>
24
#include <utility>
25
26
#include "
msgpack_rpc/clients/impl/call_future_impl.h
"
27
#include "
msgpack_rpc/common/status.h
"
28
#include "
msgpack_rpc/messages/call_result.h
"
29
30
namespace
msgpack_rpc::clients::impl
{
31
35
class
CallPromise
{
36
public
:
42
explicit
CallPromise
(std::chrono::steady_clock::time_point deadline)
43
:
future_
(
std
::make_shared<
CallFutureImpl
>(deadline)) {}
44
50
void
set
(
messages::CallResult
result) {
future_
->set(std::move(result)); }
51
57
void
set
(
const
Status
& error) {
future_
->set(error); }
58
64
[[nodiscard]] std::shared_ptr<CallFutureImpl>
future
() const noexcept {
65
return
future_
;
66
}
67
68
private
:
70
std::shared_ptr<CallFutureImpl>
future_
;
71
};
72
73
}
// namespace msgpack_rpc::clients::impl
call_future_impl.h
Definition of CallFutureImpl class.
call_result.h
Definition of CallResult class.
msgpack_rpc::clients::impl::CallFutureImpl
Class of internal implementation of future objects to get results of RPCs asynchronously.
Definition
call_future_impl.h:44
msgpack_rpc::clients::impl::CallPromise::future_
std::shared_ptr< CallFutureImpl > future_
Future.
Definition
call_promise.h.h:70
msgpack_rpc::clients::impl::CallPromise::set
void set(messages::CallResult result)
Set a result.
Definition
call_promise.h.h:50
msgpack_rpc::clients::impl::CallPromise::future
std::shared_ptr< CallFutureImpl > future() const noexcept
Get the future.
Definition
call_promise.h.h:64
msgpack_rpc::clients::impl::CallPromise::set
void set(const Status &error)
Set an error.
Definition
call_promise.h.h:57
msgpack_rpc::clients::impl::CallPromise::CallPromise
CallPromise(std::chrono::steady_clock::time_point deadline)
Constructor.
Definition
call_promise.h.h:42
msgpack_rpc::Status
Class of statuses.
Definition
status.h:34
msgpack_rpc::messages::CallResult
Class of results of methods.
Definition
call_result.h:35
msgpack_rpc::clients::impl
Namespace of internal implementations.
Definition
i_call_future_impl.h:26
std
STL namespace.
status.h
Definition of Status class.
src
msgpack_rpc
clients
impl
call_promise.h.h
Generated on
for cpp-msgpack-rpc by
1.18.0