Improve Event logging.
GitOrigin-RevId: 67a3e5f82f972b4d6b40e07215a28b6edea005c3
This commit is contained in:
parent
8efb30d34f
commit
340c98772d
@ -242,8 +242,27 @@ class Event {
|
||||
}
|
||||
};
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &sb, const Event &e) {
|
||||
return sb << tag("Event", static_cast<int32>(e.type));
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, const Event &e) {
|
||||
string_builder << "Event::";
|
||||
switch (e.type) {
|
||||
case Event::Type::Start:
|
||||
return string_builder << "Start";
|
||||
case Event::Type::Stop:
|
||||
return string_builder << "Stop";
|
||||
case Event::Type::Yield:
|
||||
return string_builder << "Yield";
|
||||
case Event::Type::Hangup:
|
||||
return string_builder << "Hangup";
|
||||
case Event::Type::Timeout:
|
||||
return string_builder << "Timeout";
|
||||
case Event::Type::Raw:
|
||||
return string_builder << "Raw";
|
||||
case Event::Type::Custom:
|
||||
return string_builder << "Custom";
|
||||
case Event::Type::NoType:
|
||||
default:
|
||||
return string_builder << "NoType";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -253,52 +253,37 @@ void Scheduler::clear() {
|
||||
void Scheduler::do_event(ActorInfo *actor_info, Event &&event) {
|
||||
event_context_ptr_->link_token = event.link_token;
|
||||
auto actor = actor_info->get_actor_unsafe();
|
||||
VLOG(actor) << *actor_info << ' ' << event;
|
||||
switch (event.type) {
|
||||
case Event::Type::Start: {
|
||||
VLOG(actor) << *actor_info << " Event::Start";
|
||||
case Event::Type::Start:
|
||||
actor->start_up();
|
||||
break;
|
||||
}
|
||||
case Event::Type::Stop: {
|
||||
VLOG(actor) << *actor_info << " Event::Stop";
|
||||
case Event::Type::Stop:
|
||||
actor->tear_down();
|
||||
break;
|
||||
}
|
||||
case Event::Type::Yield: {
|
||||
VLOG(actor) << *actor_info << " Event::Yield";
|
||||
case Event::Type::Yield:
|
||||
actor->wakeup();
|
||||
break;
|
||||
}
|
||||
case Event::Type::Hangup: {
|
||||
auto token = get_link_token(actor);
|
||||
VLOG(actor) << *actor_info << " Event::Hangup " << tag("token", format::as_hex(token));
|
||||
if (token != 0) {
|
||||
case Event::Type::Hangup:
|
||||
if (get_link_token(actor) != 0) {
|
||||
actor->hangup_shared();
|
||||
} else {
|
||||
actor->hangup();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Event::Type::Timeout: {
|
||||
VLOG(actor) << *actor_info << " Event::Timeout";
|
||||
case Event::Type::Timeout:
|
||||
actor->timeout_expired();
|
||||
break;
|
||||
}
|
||||
case Event::Type::Raw: {
|
||||
VLOG(actor) << *actor_info << " Event::Raw";
|
||||
case Event::Type::Raw:
|
||||
actor->raw_event(event.data);
|
||||
break;
|
||||
}
|
||||
case Event::Type::Custom: {
|
||||
case Event::Type::Custom:
|
||||
do_custom_event(actor_info, *event.data.custom_event);
|
||||
break;
|
||||
}
|
||||
case Event::Type::NoType: {
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
case Event::Type::NoType:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
// can't clear event here. It may be already destroyed during destory_actor
|
||||
}
|
||||
|
@ -152,7 +152,6 @@ inline void Scheduler::destroy_actor(ActorInfo *actor_info) {
|
||||
}
|
||||
|
||||
inline void Scheduler::do_custom_event(ActorInfo *actor_info, CustomEvent &event) {
|
||||
VLOG(actor) << *actor_info << " Event::Custom";
|
||||
event.run(actor_info->get_actor_unsafe());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user