• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ message_id类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中message_id的典型用法代码示例。如果您正苦于以下问题:C++ message_id类的具体用法?C++ message_id怎么用?C++ message_id使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了message_id类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: 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));
     }
 }
开发者ID:Zhouxiaoqing,项目名称:libcppa,代码行数:7,代码来源:sync_request_bouncer.hpp


示例2: 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);
}
开发者ID:YulinWu,项目名称:actor-framework,代码行数:8,代码来源:sync_request_bouncer.cpp


示例3: 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);
    }
}
开发者ID:syoummer,项目名称:boost.actor,代码行数:11,代码来源:sync_request_bouncer.cpp


示例4: apply

 static message_id apply(message_id x) {
   CAF_IGNORE_UNUSED(x);
   auto result = make_message_id(message_id::upstream_message_category
                                 << message_id::category_offset);
   CAF_ASSERT(x.is_async() || x == result);
   return result;
 }
开发者ID:xea,项目名称:actor-framework,代码行数:7,代码来源:mailbox_element.hpp


示例5: 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;
   }
 }
开发者ID:chen--oRanGe,项目名称:actor-framework,代码行数:25,代码来源:cooperative_scheduling.hpp


示例6: CPPA_REQUIRE

inline bool local_actor::awaits(message_id response_id) {
    CPPA_REQUIRE(response_id.is_response());
    return std::any_of(m_pending_responses.begin(),
                       m_pending_responses.end(),
                       [=](message_id other) {
                           return response_id == other;
                       });
}
开发者ID:Fresh1,项目名称:libcppa,代码行数:8,代码来源:local_actor.hpp


示例7:

optional<behavior&> behavior_stack::sync_handler(message_id expected_response) {
    if (expected_response.valid()) {
        auto e = m_elements.rend();
        auto i = find_if(m_elements.rbegin(), e, [=](element_type& val) {
            return val.second == expected_response;
        });
        if (i != e) return i->first;
    }
    return none;
}
开发者ID:zoujiaqing,项目名称:libcppa,代码行数:10,代码来源:behavior_stack.cpp


示例8:

response_promise::response_promise(strong_actor_ptr self,
                                   strong_actor_ptr source,
                                   forwarding_stack stages, message_id mid)
    : self_(std::move(self)),
      source_(std::move(source)),
      stages_(std::move(stages)),
      id_(mid) {
  // form an invalid request promise when initialized from a
  // response ID, since CAF always drops messages in this case
  if (mid.is_response()) {
    source_ = nullptr;
    stages_.clear();
  }
}
开发者ID:YulinWu,项目名称:actor-framework,代码行数:14,代码来源:response_promise.cpp


示例9: enqueue_impl

 void enqueue_impl(const actor_addr& sender, any_tuple msg, message_id id,
                   util::int_list<Is...>) {
     auto opt = m_map_args(std::move(msg));
     if (opt) {
         response_promise handle{this->address(), sender, id.response_id()};
         evnt_vec events;
         args_vec arguments;
         add_arguments_to_kernel<Ret>(events, arguments, m_result_size, 
                                      get_ref<Is>(*opt)...);
         auto cmd = make_counted<command<actor_facade, Ret>>(
             handle, this, 
             std::move(events), std::move(arguments),
             m_result_size, *opt
         );
         cmd->enqueue();
     } else {
         CPPA_LOGMF(CPPA_ERROR, "actor_facade::enqueue() tuple_cast failed.");
     }
 }
开发者ID:ajac,项目名称:libcppa,代码行数:19,代码来源:actor_facade.hpp


示例10: dispatch

bool instance::dispatch(const actor_addr& sender, const actor_addr& receiver,
                        message_id mid, const message& msg) {
  CAF_LOG_TRACE("");
  CAF_ASSERT(receiver.is_remote());
  auto path = lookup(receiver->node());
  if (! path) {
    notify<hook::message_sending_failed>(sender, receiver, mid, msg);
    return false;
  }
  auto writer = make_callback([&](serializer& sink) {
    msg.serialize(sink);
  });
  header hdr{message_type::dispatch_message, 0, mid.integer_value(),
             sender ? sender->node() : this_node(), receiver->node(),
             sender ? sender->id() : invalid_actor_id, receiver->id()};
  write(path->wr_buf, hdr, &writer);
  flush(*path);
  notify<hook::message_sent>(sender, path->next_hop, receiver, mid, msg);
  return true;
}
开发者ID:cmaughan,项目名称:actor-framework,代码行数:20,代码来源:basp.cpp


示例11: dispatch

bool instance::dispatch(execution_unit* ctx, const strong_actor_ptr& sender,
                        const std::vector<strong_actor_ptr>& forwarding_stack,
                        const strong_actor_ptr& receiver, message_id mid,
                        const message& msg) {
  CAF_LOG_TRACE(CAF_ARG(sender) << CAF_ARG(receiver)
                << CAF_ARG(mid) << CAF_ARG(msg));
  CAF_ASSERT(receiver && system().node() != receiver->node());
  auto path = lookup(receiver->node());
  if (! path) {
    notify<hook::message_sending_failed>(sender, receiver, mid, msg);
    return false;
  }
  auto writer = make_callback([&](serializer& sink) {
    sink << forwarding_stack << msg;
  });
  header hdr{message_type::dispatch_message, 0, 0, mid.integer_value(),
             sender ? sender->node() : this_node(), receiver->node(),
             sender ? sender->id() : invalid_actor_id, receiver->id()};
  write(ctx, path->wr_buf, hdr, &writer);
  flush(*path);
  notify<hook::message_sent>(sender, path->next_hop, receiver, mid, msg);
  return true;
}
开发者ID:alexeiz,项目名称:actor-framework,代码行数:23,代码来源:instance.cpp


示例12: 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);
 }
开发者ID:alexeiz,项目名称:actor-framework,代码行数:6,代码来源:abstract_group.hpp


示例13: invoke_fun

  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;
  }
开发者ID:ariosx,项目名称:actor-framework,代码行数:75,代码来源:invoke_policy.hpp


示例14: filter

bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
                        const strong_actor_ptr& sender, message_id mid,
                        message_view& mv, execution_unit* eu) {
  auto& content = mv.content();
  CAF_LOG_TRACE(CAF_ARG(mid) << CAF_ARG(content));
  if (content.match_elements<exit_msg>()) {
    // acquire second mutex as well
    std::vector<actor> workers;
    auto em = content.get_as<exit_msg>(0).reason;
    if (cleanup(std::move(em), eu)) {
      auto tmp = mv.move_content_to_message();
      // send exit messages *always* to all workers and clear vector afterwards
      // but first swap workers_ out of the critical section
      upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
      workers_.swap(workers);
      unique_guard.unlock();
      for (auto& w : workers)
        anon_send(w, tmp);
      unregister_from_system();
    }
    return true;
  }
  if (content.match_elements<down_msg>()) {
    // remove failed worker from pool
    auto& dm = content.get_as<down_msg>(0);
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    auto last = workers_.end();
    auto i = std::find(workers_.begin(), workers_.end(), dm.source);
    CAF_LOG_DEBUG_IF(i == last, "received down message for an unknown worker");
    if (i != last)
      workers_.erase(i);
    if (workers_.empty()) {
      planned_reason_ = exit_reason::out_of_workers;
      unique_guard.unlock();
      quit(eu);
    }
    return true;
  }
  if (content.match_elements<sys_atom, put_atom, actor>()) {
    auto& worker = content.get_as<actor>(2);
    worker->attach(default_attachable::make_monitor(worker.address(),
                                                    address()));
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    workers_.push_back(worker);
    return true;
  }
  if (content.match_elements<sys_atom, delete_atom, actor>()) {
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    auto& what = content.get_as<actor>(2);
    auto last = workers_.end();
    auto i = std::find(workers_.begin(), last, what);
    if (i != last) {
      workers_.erase(i);
    }
    return true;
  }
  if (content.match_elements<sys_atom, get_atom>()) {
    auto cpy = workers_;
    guard.unlock();
    sender->enqueue(nullptr, mid.response_id(),
                    make_message(std::move(cpy)), eu);
    return true;
  }
  if (workers_.empty()) {
    guard.unlock();
    if (sender && mid.valid()) {
      // tell client we have ignored this sync message by sending
      // and empty message back
      sender->enqueue(nullptr, mid.response_id(), message{}, eu);
    }
    return true;
  }
  return false;
}
开发者ID:crudbug,项目名称:actor-framework,代码行数:74,代码来源:actor_pool.cpp


示例15: handle_message

 handle_message_result handle_message(Actor* self, mailbox_element* node,
                                      Fun& fun, message_id awaited_response) {
   bool handle_sync_failure_on_mismatch = true;
   if (dptr()->hm_should_skip(node)) {
     return hm_skip_msg;
   }
   switch (this->filter_msg(self, node)) {
     case msg_type::normal_exit:
       CAF_LOG_DEBUG("dropped normal exit signal");
       return hm_drop_msg;
     case msg_type::expired_sync_response:
       CAF_LOG_DEBUG("dropped expired sync response");
       return hm_drop_msg;
     case msg_type::expired_timeout:
       CAF_LOG_DEBUG("dropped expired timeout message");
       return hm_drop_msg;
     case msg_type::inactive_timeout:
       CAF_LOG_DEBUG("skipped inactive timeout message");
       return hm_skip_msg;
     case msg_type::non_normal_exit:
       CAF_LOG_DEBUG("handled non-normal exit signal");
       // this message was handled
       // by calling self->quit(...)
       return hm_msg_handled;
     case msg_type::timeout: {
       CAF_LOG_DEBUG("handle timeout message");
       auto& tm = node->msg.get_as<timeout_msg>(0);
       self->handle_timeout(fun, tm.timeout_id);
       if (awaited_response.valid()) {
         self->mark_arrived(awaited_response);
         self->remove_handler(awaited_response);
       }
       return hm_msg_handled;
     }
     case msg_type::timeout_response:
       handle_sync_failure_on_mismatch = false;
       CAF_ANNOTATE_FALLTHROUGH;
     case msg_type::sync_response:
       CAF_LOG_DEBUG("handle as synchronous response: "
                << CAF_TARG(node->msg, to_string) << ", "
                << CAF_MARG(node->mid, integer_value) << ", "
                << CAF_MARG(awaited_response, integer_value));
       if (awaited_response.valid() && node->mid == awaited_response) {
         auto previous_node = dptr()->hm_begin(self, node);
         auto res = invoke_fun(self, node->msg, node->mid, fun);
         if (!res && handle_sync_failure_on_mismatch) {
           CAF_LOG_WARNING("sync failure occured in actor "
                    << "with ID " << self->id());
           self->handle_sync_failure();
         }
         self->mark_arrived(awaited_response);
         self->remove_handler(awaited_response);
         dptr()->hm_cleanup(self, previous_node);
         return hm_msg_handled;
       }
       return hm_cache_msg;
     case msg_type::ordinary:
       if (!awaited_response.valid()) {
         auto previous_node = dptr()->hm_begin(self, node);
         auto res = invoke_fun(self, node->msg, node->mid, fun);
         if (res) {
           dptr()->hm_cleanup(self, previous_node);
           return hm_msg_handled;
         }
         // no match (restore self members)
         dptr()->hm_revert(self, previous_node);
       }
       CAF_LOG_DEBUG_IF(awaited_response.valid(),
                 "ignored message; await response: "
                   << awaited_response.integer_value());
       return hm_cache_msg;
   }
   // should be unreachable
   CAF_CRITICAL("invalid message type");
 }
开发者ID:ariosx,项目名称:actor-framework,代码行数:75,代码来源:invoke_policy.hpp


示例16: is_high_priority

 inline bool is_high_priority() const {
   return mid.category() == message_id::urgent_message_category;
 }
开发者ID:xea,项目名称:actor-framework,代码行数:3,代码来源:mailbox_element.hpp


示例17: filter

bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
                        const actor_addr& sender, message_id mid,
                        const message& msg, execution_unit* eu) {
  auto rsn = planned_reason_;
  if (rsn != caf::exit_reason::not_exited) {
    guard.unlock();
    if (mid.valid()) {
      detail::sync_request_bouncer srq{rsn};
      srq(sender, mid);
    }
    return true;
  }
  if (msg.match_elements<exit_msg>()) {
    std::vector<actor> workers;
    // send exit messages *always* to all workers and clear vector afterwards
    // but first swap workers_ out of the critical section
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    workers_.swap(workers);
    planned_reason_ = msg.get_as<exit_msg>(0).reason;
    unique_guard.unlock();
    for (auto& w : workers) {
      anon_send(w, msg);
    }
    quit();
    return true;
  }
  if (msg.match_elements<down_msg>()) {
    // remove failed worker from pool
    auto& dm = msg.get_as<down_msg>(0);
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    auto last = workers_.end();
    auto i = std::find(workers_.begin(), workers_.end(), dm.source);
    if (i != last) {
      workers_.erase(i);
    }
    if (workers_.empty()) {
      planned_reason_ = exit_reason::out_of_workers;
      unique_guard.unlock();
      quit();
    }
    return true;
  }
  if (msg.match_elements<sys_atom, put_atom, actor>()) {
    auto& worker = msg.get_as<actor>(2);
    if (worker == invalid_actor) {
      return true;
    }
    worker->attach(default_attachable::make_monitor(address()));
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    workers_.push_back(worker);
    return true;
  }
  if (msg.match_elements<sys_atom, delete_atom, actor>()) {
    upgrade_to_unique_lock<detail::shared_spinlock> unique_guard{guard};
    auto& what = msg.get_as<actor>(2);
    auto last = workers_.end();
    auto i = std::find(workers_.begin(), last, what);
    if (i != last) {
      workers_.erase(i);
    }
    return true;
  }
  if (msg.match_elements<sys_atom, get_atom>()) {
    auto cpy = workers_;
    guard.unlock();
    actor_cast<abstract_actor*>(sender)->enqueue(invalid_actor_addr,
                                                 mid.response_id(),
                                                 make_message(std::move(cpy)),
                                                 eu);
    return true;
  }
  if (workers_.empty()) {
    guard.unlock();
    if (sender != invalid_actor_addr && mid.valid()) {
      // tell client we have ignored this sync message by sending
      // and empty message back
      auto ptr = actor_cast<abstract_actor_ptr>(sender);
      ptr->enqueue(invalid_actor_addr, mid.response_id(), message{}, eu);
    }
    return true;
  }
  return false;
}
开发者ID:Jenuce,项目名称:actor-framework,代码行数:83,代码来源:actor_pool.cpp


示例18:

response_promise::response_promise(const actor_addr& from,
                                   const actor_addr& to,
                                   const message_id& id)
: m_from(from), m_to(to), m_id(id) {
    CPPA_REQUIRE(id.is_response() || !id.valid());
}
开发者ID:ras0219,项目名称:libcppa,代码行数:6,代码来源:response_promise.cpp


示例19: is_high_priority

 inline bool is_high_priority() const {
   return mid.is_high_priority();
 }
开发者ID:CCJY,项目名称:actor-framework,代码行数:3,代码来源:mailbox_element.hpp



注:本文中的message_id类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ message_ptr类代码示例发布时间:2022-05-31
下一篇:
C++ message类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap