11#include "extended_error.h"
13#include <unordered_map>
49template <
typename T>
struct request_wrapper_t<T, std::enable_if_t<std::is_base_of_v<arc_base_t<T>, T>>> {
89 template <
typename... Args>
134 template <
typename... Args,
typename E = std::enable_if_t<std::is_constructible_v<raw_request_t, Args...>>>
150 template <
typename... Args>
static Response
construct(Args &&...args) {
151 return Response{std::forward<Args>(args)...};
168 return res_ptr_t{
new Response{std::forward<Args>(args)...}};
172 template <
typename T,
typename std::enable_if_t<std::is_same_v<T, res_ptr_t>>>
static res_ptr_t construct(T &&ptr) {
179template <
class T,
typename... Args>
decltype(void(T{std::declval<Args>()...}), std::true_type()) test(
int);
181template <
class T,
typename... Args> std::false_type test(...);
185template <
class T,
class... Args>
constexpr auto is_braces_constructible_v =
is_braces_constructible<T, Args...>::value;
188template <
typename T>
struct size_of_t<T> : std::is_default_constructible<T> {};
189template <
typename T,
typename... Ts>
struct size_of_t<T, Ts...> :
public std::is_constructible<T, Ts...> {};
191template <
typename T,
typename... Args>
192inline constexpr bool is_somehow_constructible_v =
193 std::is_constructible_v<T, Args...> || is_braces_constructible_v<T, Args...>;
196template <
typename T,
typename E = void,
typename... Args>
202 static constexpr auto value = std::is_default_constructible_v<T>;
208 static constexpr auto value = is_somehow_constructible_v<T, Arg>;
214 static constexpr auto value = is_somehow_constructible_v<T, Arg>;
220 static constexpr auto value = is_somehow_constructible_v<T, Args...>;
223template <
typename T,
typename... Args>
inline constexpr bool is_constructible_v =
is_constructible<T, Args...>::value;
253 static_assert(std::is_default_constructible_v<response_t>,
"response type must be default-constructible");
266 :
ee{ee_},
req{std::move(message_)} {}
274 template <
typename Response,
typename E = std::enable_if_t<std::is_same_v<response_t, std::remove_cv_t<Response>>>>
276 :
ee{ee_},
req{std::move(message_)},
res{std::forward<Response>(res_)} {}
285 template <
typename Req,
typename... Args,
286 typename E1 = std::enable_if_t<std::is_same_v<req_message_ptr_t, std::remove_cv_t<Req>>>,
289 :
ee{},
req{std::forward<Req>(message_)},
res{
res_helper_t::construct(std::forward<Args>(args)...)} {}
378 auto req_ptr = request_message_ptr(&
request);
379 auto raw_reply =
new reply_message_t{reply_to, ee, req_ptr};
390 template <
typename... Args>
399 request_id_t send(
const pt::time_duration &send)
noexcept;
403 using request_message_t =
typename traits_t::request::message_t;
404 using request_message_ptr_t =
typename traits_t::request::message_ptr_t;
405 using response_message_t =
typename traits_t::response::message_t;
406 using response_message_ptr_t =
typename traits_t::response::message_ptr_t;
407 using wrapped_res_t =
typename traits_t::response::wrapped_t;
414 bool do_install_handler;
415 request_message_ptr_t req;
418 void install_handler()
noexcept;
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< message_base_t > message_ptr_t
intrusive pointer for message
Definition message.h:118
message_ptr_t() error_producer_t(const address_ptr_t &reply_to, message_base_t &msg, const extended_error_ptr_t &ec) noexcept
free function type, which produces error response to the original request
Definition request.hpp:296
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
intrusive_ptr_t< extended_error_t > extended_error_ptr_t
intrusive pointer to extended error type
Definition extended_error.h:25
std::size_t request_id_t
timer identifier type in the scope of the actor
Definition forward.hpp:34
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
universal primitive of concurrent computation
Definition actor_base.h:47
Request cancellation payload.
Definition request.hpp:101
request_id_t id
unique (per supervisor) request id
Definition request.hpp:103
address_ptr_t source
actor address, which initiated the request
Definition request.hpp:106
Definition request.hpp:183
main helper to check constructability of T from Args...
Definition request.hpp:197
Definition request.hpp:187
Base class for rotor message.
Definition message.h:52
struct visitor_t concrete message type visitor
Definition message.h:96
the generic message meant to hold user-specific payload
Definition message.h:83
base class for request payload
Definition request.hpp:20
address_ptr_t origin
the source (original) actor address, which made an request
Definition request.hpp:32
address_ptr_t reply_to
destination address for reply
Definition request.hpp:29
request_id_t id
unique (per supervisor) request id
Definition request.hpp:22
builder pattern implementation for the original request
Definition request.hpp:387
the recorded context, which is needed to produce error response to the original request
Definition request.hpp:301
actor_base_t * source
actor, on which behalf the original request has been made
Definition request.hpp:312
message_ptr_t request_message
the original request message
Definition request.hpp:309
error_producer_t * fn
the free function, which produces error response
Definition request.hpp:303
address_ptr_t origin
destination address for the error response
Definition request.hpp:306
cancel request related types
Definition request.hpp:360
typename message_t::visitor_t visitor_t
alias for concrete message type visitor
Definition request.hpp:369
request related types
Definition request.hpp:324
intrusive_ptr_t< message_t > message_ptr_t
intrusive pointer type for request message
Definition request.hpp:335
typename message_t::visitor_t visitor_t
alias for concrete message type visitor
Definition request.hpp:338
request_t type
alias for possibly wrapped (to intrusive pointer) request payload type
Definition request.hpp:326
response related types
Definition request.hpp:343
rotor::message_t< wrapped_t > message_t
message type for wrapped response
Definition request.hpp:349
typename message_t::visitor_t visitor_t
alias for concrete message type visitor
Definition request.hpp:355
intrusive_ptr_t< message_t > message_ptr_t
intrusive pointer type for response message
Definition request.hpp:352
type helper to deduce request/response messages from original (user-supplied) request type
Definition request.hpp:318
typename request_unwrapper_t< R >::request_t request_t
alias for original request payload type
Definition request.hpp:320
static message_ptr_t make_error_response(const address_ptr_t &reply_to, message_base_t &message, const extended_error_ptr_t &ee) noexcept
helper free function to produce error reply to the original request
Definition request.hpp:373
T request_t
an alias for the original request type, if it was wrapped into intrusive poitner
Definition request.hpp:70
optionally unwraps request type from intrusive pointer
Definition request.hpp:62
T request_t
an alias for the original request type
Definition request.hpp:64
intrusive_ptr_t< T > request_t
an alias for the original request type, wrapped into intrusive pointer
Definition request.hpp:51
optionally wraps request type into intrusive pointer
Definition request.hpp:43
T request_t
an alias for the original request type
Definition request.hpp:45
static res_ptr_t construct(Args &&...args)
constructs intrusive pointer to user defined response payload
Definition request.hpp:167
static res_ptr_t construct(T &&ptr)
constructs user defined response payload and wraps it into intrusive pointer
Definition request.hpp:172
intrusive_ptr_t< Response > res_ptr_t
type for intrusive pointer user defined response payload
Definition request.hpp:161
Response response_t
Definition request.hpp:164
generic helper, which helps to construct user-defined response payload
Definition request.hpp:145
static Response construct(Args &&...args)
constructs user defined response payload
Definition request.hpp:150
Response response_t
Definition request.hpp:147
supervisor is responsible for managing actors (workers) lifetime
Definition supervisor.h:69
intrusive_ptr_t< T > request_t
alias for original request payload type wrapped into intrusive pointer
Definition request.hpp:118
request_t request_payload
intrusive pointer to user-supplied payload
Definition request.hpp:139
wrapped_request_t(request_id_t id_, const address_ptr_t &reply_to_, const address_ptr_t &origin_, const request_t &request_)
makes an intrusive pointer for already constructed user-supplied payload
Definition request.hpp:128
T raw_request_t
alias for original (unwrapped) request payload type
Definition request.hpp:115
wrapped_request_t(request_id_t id_, const address_ptr_t &reply_to_, const address_ptr_t &origin_, Args &&...args)
constructs wrapper for user-supplied payload from request-id and and destination reply address
Definition request.hpp:135
typename T::response_t response_t
alias for original (unwrapped) response payload type
Definition request.hpp:121
templated request, which is able to hold user-supplied payload
Definition request.hpp:80
T request_t
alias for original (unwrapped) request payload type
Definition request.hpp:82
wrapped_request_t(request_id_t id_, const address_ptr_t &reply_to_, const address_ptr_t &origin_, Args &&...args)
constructs wrapper for user-supplied payload from request-id and and destination reply address
Definition request.hpp:90
T request_payload
original, user-supplied payload
Definition request.hpp:94
typename T::response_t response_t
alias for original (unwrapped) response payload type
Definition request.hpp:85
trackable templated response which holds user-supplied response payload.
Definition request.hpp:234
req_message_ptr_t req
original request message, which contains request_id for request/response matching
Definition request.hpp:259
extended_error_ptr_t ee
pointer to extended error, used in the case of response failure
Definition request.hpp:256
typename request_t::response_t response_t
alias for possibly wrapped user-supplied response type
Definition request.hpp:245
intrusive_ptr_t< req_message_t > req_message_ptr_t
alias for intrusive pointer to message with wrapped request
Definition request.hpp:242
wrapped_response_t(const extended_error_ptr_t &ee_, req_message_ptr_t message_)
error-response constructor (response payload is empty)
Definition request.hpp:265
typename request_unwrapper_t< Request >::request_t request_t
alias for original user-supplied request type
Definition request.hpp:236
response_t res
user-supplied response payload
Definition request.hpp:262
wrapped_response_t(Req &&message_, Args &&...args)
successful-response constructor.
Definition request.hpp:288
typename res_helper_t::response_t unwrapped_response_t
alias user-supplied response type
Definition request.hpp:251
wrapped_response_t(req_message_ptr_t message_, const extended_error_ptr_t &ee_, Response &&res_)
"forward-constructor"
Definition request.hpp:275
request_id_t request_id() const noexcept
returns request id of the original request
Definition request.hpp:292