Exemple #1
0
 void run() {
   CAF_SET_LOGGER_SYS(&system());
   CAF_LOG_TRACE(CAF_ARG(id_));
   // scheduling loop
   for (;;) {
     auto job = policy_.dequeue(this);
     CAF_ASSERT(job != nullptr);
     CAF_ASSERT(job->subtype() != resumable::io_actor);
     CAF_LOG_DEBUG("resume actor:" << CAF_ARG(id_of(job)));
     CAF_PUSH_AID_FROM_PTR(dynamic_cast<abstract_actor*>(job));
     policy_.before_resume(this, job);
     auto res = job->resume(this, max_throughput_);
     policy_.after_resume(this, job);
     switch (res) {
       case resumable::resume_later: {
         // keep reference to this actor, as it remains in the "loop"
         policy_.resume_job_later(this, job);
         break;
       }
       case resumable::done: {
         policy_.after_completion(this, job);
         intrusive_ptr_release(job);
         break;
       }
       case resumable::awaiting_message: {
         // resumable will maybe be enqueued again later, deref it for now
         intrusive_ptr_release(job);
         break;
       }
       case resumable::shutdown_execution_unit: {
         policy_.after_completion(this, job);
         policy_.before_shutdown(this);
         return;
       }
     }
   }
 }
 void run() {
   CAF_LOG_TRACE("worker with ID " << m_id);
   // scheduling loop
   for (;;) {
     auto job = m_queue_policy.internal_dequeue(this);
     CAF_REQUIRE(job != nullptr);
     CAF_LOG_DEBUG("resume actor " << id_of(job));
     CAF_PUSH_AID_FROM_PTR(dynamic_cast<abstract_actor*>(job));
     switch (job->resume(this)) {
       case resumable::done: {
         job->detach_from_scheduler();
         break;
       }
       case resumable::resume_later: {
         break;
       }
       case resumable::shutdown_execution_unit: {
         m_queue_policy.clear_internal_queue(this);
         return;
       }
     }
     m_queue_policy.assert_stealable(this);
   }
 }