本文整理汇总了C++中message::type_token方法的典型用法代码示例。如果您正苦于以下问题:C++ message::type_token方法的具体用法?C++ message::type_token怎么用?C++ message::type_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::type_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invoke
bhvr_invoke_result behavior_impl::invoke(message& msg) {
auto msg_token = msg.type_token();
bhvr_invoke_result res;
for (auto i = begin_; i != end_; ++i) {
if ((i->has_wildcard || i->type_token == msg_token)
&& i->ptr->invoke(res, msg) != match_case::no_match) {
return res;
}
}
return none;
}
示例2: deliver
void basp_broker_state::deliver(const node_id& src_nid, actor_id src_aid,
strong_actor_ptr dest, message_id mid,
std::vector<strong_actor_ptr>& stages,
message& msg) {
CAF_LOG_TRACE(CAF_ARG(src_nid) << CAF_ARG(src_aid) << CAF_ARG(dest)
<< CAF_ARG(msg) << CAF_ARG(mid));
auto src = src_nid == this_node() ? system().registry().get(src_aid)
: proxies().get_or_put(src_nid, src_aid);
// Intercept link messages. Forwarding actor proxies signalize linking
// by sending link_atom/unlink_atom message with src = dest.
if (msg.type_token() == make_type_token<atom_value, strong_actor_ptr>()) {
switch (static_cast<uint64_t>(msg.get_as<atom_value>(0))) {
default:
break;
case link_atom::value.uint_value(): {
if (src_nid != this_node()) {
CAF_LOG_WARNING("received link message for an other node");
return;
}
auto ptr = msg.get_as<strong_actor_ptr>(1);
if (!ptr) {
CAF_LOG_WARNING("received link message with invalid target");
return;
}
if (!src) {
CAF_LOG_DEBUG("received link for invalid actor, report error");
anon_send(actor_cast<actor>(ptr),
make_error(sec::remote_linking_failed));
return;
}
static_cast<actor_proxy*>(ptr->get())->local_link_to(src->get());
return;
}
case unlink_atom::value.uint_value(): {
if (src_nid != this_node()) {
CAF_LOG_WARNING("received unlink message for an other node");
return;
}
auto ptr = msg.get_as<strong_actor_ptr>(1);
if (!ptr) {
CAF_LOG_DEBUG("received unlink message with invalid target");
return;
}
if (!src) {
CAF_LOG_DEBUG("received unlink for invalid actor, report error");
return;
}
static_cast<actor_proxy*>(ptr->get())->local_unlink_from(src->get());
return;
}
}
}
if (!dest) {
auto rsn = exit_reason::remote_link_unreachable;
CAF_LOG_INFO("cannot deliver message, destination not found");
self->parent().notify<hook::invalid_message_received>(src_nid, src,
invalid_actor_id,
mid, msg);
if (mid.valid() && src) {
detail::sync_request_bouncer srb{rsn};
srb(src, mid);
}
return;
}
self->parent().notify<hook::message_received>(src_nid, src, dest, mid, msg);
dest->enqueue(make_mailbox_element(std::move(src), mid, std::move(stages),
std::move(msg)),
nullptr);
}