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

Method Wait

library/cpp/netliba/v6/udp_client_server.cpp:473–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471 void IBStep() override;
472
473 void Wait(float seconds) override {
474 if (seconds < 1e-3)
475 seconds = 0;
476 if (seconds > MaxWaitTime)
477 seconds = MaxWaitTime;
478 if (IBIdleTime < 0.010) {
479 seconds = 0;
480 }
481 if (seconds == 0) {
482 ThreadYield();
483 } else {
484 AtomicAdd(IsWaiting, 1);
485 if (seconds > MaxWaitTime2)
486 seconds = MaxWaitTime2;
487 MaxWaitTime2 = DEFAULT_MAX_WAIT_TIME;
488
489 if (seconds == 0) {
490 ThreadYield();
491 } else {
492 if (IB.Get()) {
493 for (float done = 0; done < seconds;) {
494 float deltaSleep = Min(seconds - done, 0.002f);
495 s.Wait(deltaSleep);
496 NHPTimer::STime tChk;
497 NHPTimer::GetTime(&tChk);
498 if (IB->Step(tChk)) {
499 IBIdleTime = 0;
500 break;
501 }
502 done += deltaSleep;
503 }
504 } else {
505 s.Wait(seconds);
506 }
507 }
508 AtomicAdd(IsWaiting, -1);
509 }
510 }
511
512 void CancelWait() override {
513 MaxWaitTime2 = 0;

Callers

nothing calls this directly

Calls 5

ThreadYieldFunction · 0.85
AtomicAddFunction · 0.50
MinFunction · 0.50
GetMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected