Move common code to a non-template function.
This commit is contained in:
parent
36ace421b8
commit
44b548c307
@ -199,6 +199,9 @@ class Scheduler {
|
||||
|
||||
void flush_mailbox(ActorInfo *actor_info);
|
||||
|
||||
void get_actor_sched_id(const ActorInfo *actor_info, int32 &actor_sched_id, bool &on_current_sched,
|
||||
bool &can_send_immediately);
|
||||
|
||||
template <ActorSendType send_type, class RunFuncT, class EventFuncT>
|
||||
void send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, const EventFuncT &event_func);
|
||||
|
||||
|
@ -301,6 +301,15 @@ void Scheduler::do_event(ActorInfo *actor_info, Event &&event) {
|
||||
// can't clear event here. It may be already destroyed during destroy_actor
|
||||
}
|
||||
|
||||
void Scheduler::get_actor_sched_id(const ActorInfo *actor_info, int32 &actor_sched_id, bool &on_current_sched,
|
||||
bool &can_send_immediately) {
|
||||
bool is_migrating;
|
||||
std::tie(actor_sched_id, is_migrating) = actor_info->migrate_dest_flag_atomic();
|
||||
on_current_sched = !is_migrating && sched_id_ == actor_sched_id;
|
||||
CHECK(has_guard_ || !on_current_sched);
|
||||
can_send_immediately = on_current_sched && !actor_info->is_running() && actor_info->mailbox_.empty();
|
||||
}
|
||||
|
||||
void Scheduler::register_migrated_actor(ActorInfo *actor_info) {
|
||||
VLOG(actor) << "Register migrated actor " << *actor_info << ", " << tag("actor_count", actor_count_);
|
||||
actor_count_++;
|
||||
|
@ -186,13 +186,11 @@ void Scheduler::send_impl(const ActorId<> &actor_id, const RunFuncT &run_func, c
|
||||
}
|
||||
|
||||
int32 actor_sched_id;
|
||||
bool is_migrating;
|
||||
std::tie(actor_sched_id, is_migrating) = actor_info->migrate_dest_flag_atomic();
|
||||
bool on_current_sched = !is_migrating && sched_id_ == actor_sched_id;
|
||||
CHECK(has_guard_ || !on_current_sched);
|
||||
bool on_current_sched;
|
||||
bool can_send_immediately;
|
||||
get_actor_sched_id(actor_info, actor_sched_id, on_current_sched, can_send_immediately);
|
||||
|
||||
if (likely(send_type == ActorSendType::Immediate && on_current_sched && !actor_info->is_running() &&
|
||||
actor_info->mailbox_.empty())) { // run immediately
|
||||
if (likely(send_type == ActorSendType::Immediate && can_send_immediately)) { // run immediately
|
||||
EventGuard guard(this, actor_info);
|
||||
run_func(actor_info);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user