Respect timeout in run_events.

This commit is contained in:
levlam 2021-10-06 17:16:23 +03:00
parent 223e620653
commit bbae7be409
3 changed files with 14 additions and 14 deletions

View File

@ -196,7 +196,7 @@ class Scheduler {
Timestamp run_timeout(); Timestamp run_timeout();
void run_mailbox(); void run_mailbox();
Timestamp run_events(); Timestamp run_events(Timestamp timeout);
void run_poll(Timestamp timeout); void run_poll(Timestamp timeout);
template <class ActorT> template <class ActorT>

View File

@ -487,18 +487,29 @@ Timestamp Scheduler::run_timeout() {
return get_timeout(); return get_timeout();
} }
Timestamp Scheduler::run_events(Timestamp timeout) {
Timestamp res;
VLOG(actor) << "Run events " << sched_id_ << " " << tag("pending", pending_events_.size())
<< tag("actors", actor_count_);
do {
run_mailbox();
res = run_timeout();
} while (!ready_actors_list_.empty() && !timeout.is_in_past());
return res;
}
void Scheduler::run_no_guard(Timestamp timeout) { void Scheduler::run_no_guard(Timestamp timeout) {
CHECK(has_guard_); CHECK(has_guard_);
SCOPE_EXIT { SCOPE_EXIT {
yield_flag_ = false; yield_flag_ = false;
}; };
timeout.relax(run_events()); timeout.relax(run_events(timeout));
if (yield_flag_) { if (yield_flag_) {
return; return;
} }
run_poll(timeout); run_poll(timeout);
run_events(); run_events(timeout);
} }
Timestamp Scheduler::get_timeout() { Timestamp Scheduler::get_timeout() {

View File

@ -345,17 +345,6 @@ inline void Scheduler::wakeup() {
#endif #endif
} }
inline Timestamp Scheduler::run_events() {
Timestamp res;
VLOG(actor) << "Run events " << sched_id_ << " " << tag("pending", pending_events_.size())
<< tag("actors", actor_count_);
do {
run_mailbox();
res = run_timeout();
} while (!ready_actors_list_.empty());
return res;
}
inline void Scheduler::run(Timestamp timeout) { inline void Scheduler::run(Timestamp timeout) {
auto guard = get_guard(); auto guard = get_guard();
run_no_guard(timeout); run_no_guard(timeout);