inline std::pair<aid_t, bool> respond_impl( Tag, Recver& recver, resp_t res, message& msg, duration_t tmo, recv_meta meta = recv_meta() ) { aid_t sender = recver.respond(res, msg, tmo); if (msg.get_type() == exit) { if (meta.guard_ != 0) { *meta.guard_ = boost::asio::error::make_error_code(boost::asio::error::shut_down); return std::make_pair(sender, false); } else { exit_code_t exc; std::string errmsg; msg >> exc >> errmsg; if (exc == exit_normal) { GCE_VERIFY(false)(exc)(res)(msg)(sender)(tmo) .msg("gce::normal_exception").except<normal_exception>(); } else if (exc == exit_except) { GCE_VERIFY(false)(exc)(res)(msg)(sender)(tmo) .msg("gce::runtime_exception").except<runtime_exception>(); } else if (exc == exit_remote) { GCE_VERIFY(false)(exc)(res)(msg)(sender)(tmo) .msg("gce::remote_exception").except<remote_exception>(); } else if (exc == exit_already) { GCE_VERIFY(false)(exc)(res)(msg)(sender)(tmo) .msg("gce::already_exit_exception").except<already_exit_exception>(); } else if (exc == exit_neterr) { GCE_VERIFY(false)(exc)(res)(msg)(sender)(tmo) .msg("gce::neterr_exception").except<neterr_exception>(); } else { GCE_ASSERT(false)(exc)(errmsg); } } } if (sender == aid_nil && meta.tmo_ != 0) { *meta.tmo_ = boost::asio::error::make_error_code(boost::asio::error::timed_out); return std::make_pair(sender, false); } GCE_VERIFY(sender != aid_nil)(res)(msg)(tmo) .msg("gce::respond_timeout_exception").except<respond_timeout_exception>(); return std::make_pair(sender, true); }
inline std::pair<aid_t, bool> recv_impl( gce::nonblocked, Recver& recver, message& msg, pattern& patt, recv_meta meta = recv_meta() ) { bool has_exit = check_exit(patt.match_list_); aid_t sender = recver.recv(msg, patt.match_list_, patt.recver_); if (meta.matched_ != 0) { *meta.matched_ = msg.get_type(); } if (!has_exit && msg.get_type() == exit) { if (meta.guard_ != 0) { *meta.guard_ = boost::asio::error::make_error_code(boost::asio::error::shut_down); return std::make_pair(sender, false); } else { exit_code_t exc; std::string errmsg; msg >> exc >> errmsg; if (exc == exit_normal) { GCE_VERIFY(false)(exc)(msg)(patt)(sender) .msg("gce::normal_exception").except<normal_exception>(); } else if (exc == exit_except) { GCE_VERIFY(false)(exc)(msg)(patt)(sender) .msg("gce::runtime_exception").except<runtime_exception>(); } else if (exc == exit_remote) { GCE_VERIFY(false)(exc)(msg)(patt)(sender) .msg("gce::remote_exception").except<remote_exception>(); } else if (exc == exit_already) { GCE_VERIFY(false)(exc)(msg)(patt)(sender) .msg("gce::already_exit_exception").except<already_exit_exception>(); } else if (exc == exit_neterr) { GCE_VERIFY(false)(exc)(msg)(patt)(sender) .msg("gce::neterr_exception").except<neterr_exception>(); } else { GCE_ASSERT(false)(exc)(errmsg); } } } return std::make_pair(sender, sender != aid_nil); }
inline aid_t recv(Recver& recver, message& msg, match& mach) { bool add_exit = check_exit(mach.match_list_); if (add_exit) { mach.match_list_.push_back(exit); } aid_t sender = recver.recv(msg, mach); if (add_exit && msg.get_type() == exit) { exit_code_t exc; std::string errmsg; msg >> exc >> errmsg; throw std::runtime_error(errmsg); }