Ejemplo n.º 1
0
void local_actor::delayed_send_tuple(message_priority prio,
                                     const channel& dest,
                                     const util::duration& rel_time,
                                     cppa::any_tuple msg) {
    message_id mid;
    if (prio == message_priority::high) mid = mid.with_high_priority();
    get_scheduling_coordinator()->delayed_send({address(), dest, mid},
                                  rel_time, std::move(msg));
}
Ejemplo n.º 2
0
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;
}
 void enqueue(Actor* self, msg_hdr_cref hdr,
              message& msg, execution_unit* host) {
     auto e = self->new_mailbox_element(hdr, std::move(msg));
     switch (self->mailbox().enqueue(e)) {
         case detail::enqueue_result::unblocked_reader: {
             // re-schedule actor
             if (host) host->exec_later(self);
             else get_scheduling_coordinator()->enqueue(self);
             break;
         }
         case detail::enqueue_result::queue_closed: {
             if (hdr.id.is_request()) {
                 detail::sync_request_bouncer f{self->exit_reason()};
                 f(hdr.sender, hdr.id);
             }
             break;
         }
         case detail::enqueue_result::success:
             // enqueued to a running actors' mailbox; nothing to do
             break;
     }
 }
 inline void launch(Actor* self, execution_unit* host) {
     // detached in scheduler::worker::run
     self->attach_to_scheduler();
     if (host) host->exec_later(self);
     else get_scheduling_coordinator()->enqueue(self);
 }