diff --git a/tdactor/td/actor/impl/ActorInfo-decl.h b/tdactor/td/actor/impl/ActorInfo-decl.h index 870e26dff..9af073f02 100644 --- a/tdactor/td/actor/impl/ActorInfo-decl.h +++ b/tdactor/td/actor/impl/ActorInfo-decl.h @@ -108,15 +108,13 @@ class ActorInfo final bool need_context() const; bool need_start_up() const; - void set_wait_generation(uint32 wait_generation); - bool must_wait(uint32 wait_generation) const; + bool must_wait() const; private: Deleter deleter_ = Deleter::None; bool need_context_ = true; bool need_start_up_ = true; bool is_running_ = false; - uint32 wait_generation_{0}; std::atomic sched_id_{0}; Actor *actor_ = nullptr; diff --git a/tdactor/td/actor/impl/ActorInfo.h b/tdactor/td/actor/impl/ActorInfo.h index 714ce43bd..16e1cfe77 100644 --- a/tdactor/td/actor/impl/ActorInfo.h +++ b/tdactor/td/actor/impl/ActorInfo.h @@ -50,7 +50,6 @@ inline void ActorInfo::init(int32 sched_id, Slice name, ObjectPool::O need_context_ = need_context; need_start_up_ = need_start_up; is_running_ = false; - wait_generation_ = 0; } inline bool ActorInfo::need_context() const { @@ -61,12 +60,8 @@ inline bool ActorInfo::need_start_up() const { return need_start_up_; } -inline void ActorInfo::set_wait_generation(uint32 wait_generation) { - wait_generation_ = wait_generation; -} - -inline bool ActorInfo::must_wait(uint32 wait_generation) const { - return wait_generation_ == wait_generation || !mailbox_.empty(); +inline bool ActorInfo::must_wait() const { + return !mailbox_.empty(); } inline void ActorInfo::on_actor_moved(Actor *actor_new_ptr) { diff --git a/tdactor/td/actor/impl/Scheduler-decl.h b/tdactor/td/actor/impl/Scheduler-decl.h index dd1816a77..c4f827768 100644 --- a/tdactor/td/actor/impl/Scheduler-decl.h +++ b/tdactor/td/actor/impl/Scheduler-decl.h @@ -200,8 +200,6 @@ class Scheduler { template void send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func); - void inc_wait_generation(); - Timestamp run_timeout(); void run_mailbox(); Timestamp run_events(Timestamp timeout); @@ -231,7 +229,6 @@ class Scheduler { bool has_guard_ = false; bool close_flag_ = false; - uint32 wait_generation_ = 1; int32 sched_id_ = 0; int32 sched_n_ = 0; std::shared_ptr> inbound_queue_; diff --git a/tdactor/td/actor/impl/Scheduler.cpp b/tdactor/td/actor/impl/Scheduler.cpp index f38ef1def..64a1e1423 100644 --- a/tdactor/td/actor/impl/Scheduler.cpp +++ b/tdactor/td/actor/impl/Scheduler.cpp @@ -497,7 +497,6 @@ void Scheduler::run_mailbox() { ListNode *node = actors_list.get(); CHECK(node); auto actor_info = ActorInfo::from_list_node(node); - inc_wait_generation(); flush_mailbox(actor_info, static_cast(nullptr), static_cast(nullptr)); } VLOG(actor) << "Run mailbox : finish " << actor_count_; @@ -526,7 +525,6 @@ Timestamp Scheduler::run_timeout() { while (!timeout_queue_.empty() && timeout_queue_.top_key() < now) { HeapNode *node = timeout_queue_.pop(); ActorInfo *actor_info = ActorInfo::from_heap_node(node); - inc_wait_generation(); send(actor_info->actor_id(), Event::timeout()); } return get_timeout(); diff --git a/tdactor/td/actor/impl/Scheduler.h b/tdactor/td/actor/impl/Scheduler.h index 176dbe425..298c3a05c 100644 --- a/tdactor/td/actor/impl/Scheduler.h +++ b/tdactor/td/actor/impl/Scheduler.h @@ -191,10 +191,6 @@ inline void Scheduler::before_tail_send(const ActorId<> &actor_id) { // TODO } -inline void Scheduler::inc_wait_generation() { - wait_generation_ += 2; -} - template void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func) { ActorInfo *actor_info = actor_id.get_actor_info(); @@ -210,7 +206,7 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c CHECK(has_guard_ || !on_current_sched); if (likely(send_type == ActorSendType::Immediate && on_current_sched && !actor_info->is_running() && - !actor_info->must_wait(wait_generation_))) { // run immediately + !actor_info->must_wait())) { // run immediately if (likely(actor_info->mailbox_.empty())) { EventGuard guard(this, actor_info); run_func(actor_info); @@ -220,9 +216,6 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c } else { if (on_current_sched) { add_to_mailbox(actor_info, event_func()); - if (send_type == ActorSendType::Later) { - actor_info->set_wait_generation(wait_generation_); - } } else { send_to_scheduler(actor_sched_id, actor_id, event_func()); }