Remove legacy parameters in Scheduler::flush_mailbox.
This commit is contained in:
parent
b6b5b1b9ed
commit
516e2e8a07
@ -194,8 +194,7 @@ class Scheduler {
|
||||
void add_to_mailbox(ActorInfo *actor_info, Event &&event);
|
||||
void clear_mailbox(ActorInfo *actor_info);
|
||||
|
||||
template <class RunFuncT, class EventFuncT>
|
||||
void flush_mailbox(ActorInfo *actor_info, const RunFuncT &run_func, const EventFuncT &event_func);
|
||||
void flush_mailbox(ActorInfo *actor_info);
|
||||
|
||||
template <ActorSendType send_type, class RunFuncT, class EventFuncT>
|
||||
void send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func);
|
||||
|
@ -493,6 +493,18 @@ void Scheduler::run_poll(Timestamp timeout) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Scheduler::flush_mailbox(ActorInfo *actor_info) {
|
||||
auto &mailbox = actor_info->mailbox_;
|
||||
size_t mailbox_size = mailbox.size();
|
||||
CHECK(mailbox_size != 0);
|
||||
EventGuard guard(this, actor_info);
|
||||
size_t i = 0;
|
||||
for (; i < mailbox_size && guard.can_run(); i++) {
|
||||
do_event(actor_info, std::move(mailbox[i]));
|
||||
}
|
||||
mailbox.erase(mailbox.begin(), mailbox.begin() + i);
|
||||
}
|
||||
|
||||
void Scheduler::run_mailbox() {
|
||||
VLOG(actor) << "Run mailbox : begin";
|
||||
ListNode actors_list = std::move(ready_actors_list_);
|
||||
@ -500,7 +512,7 @@ void Scheduler::run_mailbox() {
|
||||
ListNode *node = actors_list.get();
|
||||
CHECK(node);
|
||||
auto actor_info = ActorInfo::from_list_node(node);
|
||||
flush_mailbox(actor_info, static_cast<void (*)(ActorInfo *)>(nullptr), static_cast<Event (*)()>(nullptr));
|
||||
flush_mailbox(actor_info);
|
||||
}
|
||||
VLOG(actor) << "Run mailbox : finish " << actor_count_;
|
||||
|
||||
|
@ -140,26 +140,6 @@ inline void Scheduler::destroy_actor(ActorInfo *actor_info) {
|
||||
CHECK(actor_count_ >= 0);
|
||||
}
|
||||
|
||||
template <class RunFuncT, class EventFuncT>
|
||||
void Scheduler::flush_mailbox(ActorInfo *actor_info, const RunFuncT &run_func, const EventFuncT &event_func) {
|
||||
auto &mailbox = actor_info->mailbox_;
|
||||
size_t mailbox_size = mailbox.size();
|
||||
CHECK(mailbox_size != 0);
|
||||
EventGuard guard(this, actor_info);
|
||||
size_t i = 0;
|
||||
for (; i < mailbox_size && guard.can_run(); i++) {
|
||||
do_event(actor_info, std::move(mailbox[i]));
|
||||
}
|
||||
if (run_func) {
|
||||
if (guard.can_run()) {
|
||||
(*run_func)(actor_info);
|
||||
} else {
|
||||
mailbox.insert(mailbox.begin() + i, (*event_func)());
|
||||
}
|
||||
}
|
||||
mailbox.erase(mailbox.begin(), mailbox.begin() + i);
|
||||
}
|
||||
|
||||
inline void Scheduler::send_to_scheduler(int32 sched_id, const ActorId<Actor> &actor_id, Event &&event) {
|
||||
if (sched_id == sched_id_) {
|
||||
ActorInfo *actor_info = actor_id.get_actor_info();
|
||||
|
Loading…
Reference in New Issue
Block a user