本文整理汇总了C++中message_id::is_request方法的典型用法代码示例。如果您正苦于以下问题:C++ message_id::is_request方法的具体用法?C++ message_id::is_request怎么用?C++ message_id::is_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message_id
的用法示例。
在下文中一共展示了message_id::is_request方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enqueue
void enqueue(Actor* self, const actor_addr& sender, message_id mid,
message& msg, execution_unit* eu) {
auto e = self->new_mailbox_element(sender, mid, std::move(msg));
switch (self->mailbox().enqueue(e)) {
case detail::enqueue_result::unblocked_reader: {
// re-schedule actor
if (eu)
eu->exec_later(self);
else
detail::singletons::get_scheduling_coordinator()->enqueue(
self);
break;
}
case detail::enqueue_result::queue_closed: {
if (mid.is_request()) {
detail::sync_request_bouncer f{self->exit_reason()};
f(sender, mid);
}
break;
}
case detail::enqueue_result::success:
// enqueued to a running actors' mailbox; nothing to do
break;
}
}
示例2: operator
inline void operator()(const actor_ptr& sender, const message_id& mid) const {
CPPA_REQUIRE(rsn != exit_reason::not_exited);
if (mid.is_request() && sender != nullptr) {
sender->enqueue({nullptr, sender, mid.response_id()},
make_any_tuple(atom("EXITED"), rsn));
}
}
示例3: operator
void sync_request_bouncer::operator()(const strong_actor_ptr& sender,
const message_id& mid) const {
if (sender && mid.is_request())
sender->enqueue(nullptr, mid.response_id(),
make_message(make_error(sec::request_receiver_down)),
// TODO: this breaks out of the execution unit
nullptr);
}
示例4: operator
void sync_request_bouncer::operator()(const actor_addr& sender,
const message_id& mid) const {
BOOST_ACTOR_REQUIRE(rsn != exit_reason::not_exited);
if (sender && mid.is_request()) {
auto ptr = detail::raw_access::get(sender);
ptr->enqueue({invalid_actor_addr, ptr, mid.response_id()},
make_message(sync_exited_msg{sender, rsn}),
// TODO: this breaks out of the execution unit
nullptr);
}
}
示例5: eq_impl
void eq_impl(message_id mid, strong_actor_ptr sender,
execution_unit* ctx, Ts&&... xs) {
CAF_ASSERT(! mid.is_request());
enqueue(std::move(sender), mid,
make_message(std::forward<Ts>(xs)...), ctx);
}
示例6: move
optional<message> invoke_fun(Actor* self, message& msg, message_id& mid,
Fun& fun,
MaybeResponseHdl hdl = MaybeResponseHdl{}) {
# ifdef CAF_LOG_LEVEL
auto msg_str = to_string(msg);
# endif
CAF_LOG_TRACE(CAF_MARG(mid, integer_value) << ", msg = " << msg_str);
auto res = fun(msg); // might change mid
CAF_LOG_DEBUG_IF(res, "actor did consume message: " << msg_str);
CAF_LOG_DEBUG_IF(!res, "actor did ignore message: " << msg_str);
if (!res) {
return none;
}
if (res->empty()) {
// make sure synchronous requests
// always receive a response
if (mid.is_request() && !mid.is_answered()) {
CAF_LOG_WARNING("actor with ID " << self->id()
<< " did not reply to a synchronous request message");
auto fhdl = fetch_response_promise(self, hdl);
if (fhdl) {
fhdl.deliver(make_message(unit));
}
}
} else {
CAF_LOGF_DEBUG("res = " << to_string(*res));
if (res->template has_types<atom_value, uint64_t>()
&& res->template get_as<atom_value>(0) == atom("MESSAGE_ID")) {
CAF_LOG_DEBUG("message handler returned a message id wrapper");
auto id = res->template get_as<uint64_t>(1);
auto msg_id = message_id::from_integer_value(id);
auto ref_opt = self->sync_handler(msg_id);
// calls self->response_promise() if hdl is a dummy
// argument, forwards hdl otherwise to reply to the
// original request message
auto fhdl = fetch_response_promise(self, hdl);
if (ref_opt) {
behavior cpy = *ref_opt;
*ref_opt =
cpy.add_continuation([=](message & intermediate)
->optional<message> {
if (!intermediate.empty()) {
// do no use lamba expresion type to
// avoid recursive template instantiaton
behavior::continuation_fun f2 = [=](
message & m)->optional<message> {
return std::move(m);
};
auto mutable_mid = mid;
// recursively call invoke_fun on the
// result to correctly handle stuff like
// sync_send(...).then(...).then(...)...
return this->invoke_fun(self, intermediate,
mutable_mid, f2, fhdl);
}
return none;
});
}
// reset res to prevent "outer" invoke_fun
// from handling the result again
res->reset();
} else {
// respond by using the result of 'fun'
CAF_LOG_DEBUG("respond via response_promise");
auto fhdl = fetch_response_promise(self, hdl);
if (fhdl) {
fhdl.deliver(std::move(*res));
// inform caller about success
return message{};
}
}
}
return res;
}