void send_message(actor& source, actor& target, const std::string& message) { ac_message_t msg; msg.src = &source; msg.message = message; target.enqueue(msg); }
message_id local_actor::sync_send_tuple_impl(message_priority mp, const actor& dest, any_tuple&& what) { auto nri = new_request_id(); if (mp == message_priority::high) nri = nri.with_high_priority(); dest->enqueue({address(), dest, nri}, std::move(what)); return nri.response_id(); }
void local_actor::forward_message(const actor& dest, message_priority prio) { if (!dest) { return; } auto id = (prio == message_priority::high) ? m_current_node->mid.with_high_priority() : m_current_node->mid.with_normal_priority(); dest->enqueue(m_current_node->sender, id, m_current_node->msg, host()); // treat this message as asynchronous message from now on m_current_node->mid = invalid_message_id; }
void delegate(message_priority mp, const actor& dest, Ts&&... xs) { static_assert(sizeof...(Ts) > 0, "no message to send"); if (! dest) return; auto mid = current_element_->mid; current_element_->mid = mp == message_priority::high ? mid.with_high_priority() : mid.with_normal_priority(); current_element_->msg = make_message(std::forward<Ts>(xs)...); dest->enqueue(std::move(current_element_), host()); }
message_id local_actor::sync_send_tuple_impl(message_priority mp, const actor& dest, any_tuple&& what) { if (!dest) { throw std::invalid_argument("cannot send synchronous message " "to invalid_actor"); } auto nri = new_request_id(); if (mp == message_priority::high) nri = nri.with_high_priority(); dest->enqueue({address(), dest, nri}, std::move(what), m_host); return nri.response_id(); }
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp, const actor& dest, const util::duration& rtime, any_tuple&& what) { auto nri = new_request_id(); if (mp == message_priority::high) nri = nri.with_high_priority(); dest->enqueue({address(), dest, nri}, std::move(what)); auto rri = nri.response_id(); get_scheduler()->delayed_send({address(), this, rri}, rtime, make_any_tuple(sync_timeout_msg{})); return rri; }
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp, const actor& dest, const util::duration& rtime, any_tuple&& what) { if (!dest) { throw std::invalid_argument("cannot send synchronous message " "to invalid_actor"); } auto nri = new_request_id(); if (mp == message_priority::high) nri = nri.with_high_priority(); dest->enqueue({address(), dest, nri}, std::move(what), m_host); auto rri = nri.response_id(); get_scheduling_coordinator()->delayed_send({address(), this, rri}, rtime, make_any_tuple(sync_timeout_msg{})); return rri; }
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp, const actor& dest, const duration& rtime, message&& what) { if (!dest) { throw std::invalid_argument( "cannot send synchronous message " "to invalid_actor"); } auto nri = new_request_id(); if (mp == message_priority::high) { nri = nri.with_high_priority(); } dest->enqueue(address(), nri, std::move(what), host()); auto rri = nri.response_id(); auto sched_cd = detail::singletons::get_scheduling_coordinator(); sched_cd->delayed_send(rtime, address(), this, rri, make_message(sync_timeout_msg{})); return rri; }