MCPcopy Create free account
hub / github.com/catboost/catboost / RunScheduler

Method RunScheduler

library/cpp/coroutine/engine/impl.cpp:310–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310void TContExecutor::RunScheduler() noexcept {
311 try {
312 TContExecutor* const prev = ThisThreadExecutor();
313 ThisThreadExecutor() = this;
314 TCont* caller = Current_;
315 TExceptionSafeContext* context = caller ? caller->Trampoline_.Context() : &SchedContext_;
316 Y_DEFER {
317 ThisThreadExecutor() = prev;
318 };
319
320 while (true) {
321 if (ScheduleCallback_ && Current_) {
322 ScheduleCallback_->OnUnschedule(*this);
323 }
324
325 WaitForIO();
326 DeleteScheduled();
327 Ready_.Append(ReadyNext_);
328
329 if (Ready_.Empty()) {
330 Current_ = nullptr;
331 if (caller) {
332 context->SwitchTo(&SchedContext_);
333 }
334 break;
335 }
336
337 TCont* cont = Ready_.PopFront();
338
339 if (ScheduleCallback_) {
340 ScheduleCallback_->OnSchedule(*this, *cont);
341 }
342
343 Current_ = cont;
344 cont->Scheduled_ = false;
345 if (cont == caller) {
346 break;
347 }
348 context->SwitchTo(cont->Trampoline_.Context());
349 if (Paused_) {
350 Paused_ = false;
351 Current_ = nullptr;
352 break;
353 }
354 if (caller) {
355 break;
356 }
357 }
358 } catch (...) {
359 TBackTrace::FromCurrentException().PrintTo(Cerr);
360 Y_ABORT("Uncaught exception in the scheduler: %s", CurrentExceptionMessage().c_str());
361 }
362}
363
364void TContExecutor::Pause() {
365 if (auto cont = Running()) {

Callers 1

SwitchMethod · 0.80

Calls 8

CurrentExceptionMessageFunction · 0.85
ContextMethod · 0.45
AppendMethod · 0.45
EmptyMethod · 0.45
SwitchToMethod · 0.45
PopFrontMethod · 0.45
PrintToMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected