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

Method WaitLow

library/cpp/netliba/v12/udp_host.cpp:1759–1796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1757 }
1758
1759 void TUdpHost::WaitLow(float seconds) {
1760 if (seconds < 1e-3)
1761 seconds = 0;
1762 if (seconds > MaxWaitTime)
1763 seconds = MaxWaitTime;
1764 if (IBIdleTime < 0.010) {
1765 seconds = 0;
1766 }
1767 if (seconds == 0) {
1768 ThreadYield();
1769 } else {
1770 AtomicAdd(IsWaiting, 1);
1771 if (seconds > MaxWaitTime2.load(std::memory_order_acquire))
1772 seconds = MaxWaitTime2.load(std::memory_order_acquire);
1773 MaxWaitTime2.store(DEFAULT_MAX_WAIT_TIME, std::memory_order_release);
1774
1775 if (seconds == 0) {
1776 ThreadYield();
1777 } else {
1778 if (IB.Get()) {
1779 for (float done = 0; done < seconds;) {
1780 float deltaSleep = Min(seconds - done, 0.002f);
1781 S.Wait(deltaSleep);
1782 NHPTimer::STime tChk;
1783 NHPTimer::GetTime(&tChk);
1784 if (IB->Step(tChk)) {
1785 IBIdleTime = 0;
1786 break;
1787 }
1788 done += deltaSleep;
1789 }
1790 } else {
1791 S.Wait(seconds);
1792 }
1793 }
1794 AtomicAdd(IsWaiting, -1);
1795 }
1796 }
1797
1798 void TUdpHost::CancelWait() {
1799 Event.Signal();

Callers 1

ExecServerThreadMethod · 0.80

Calls 8

ThreadYieldFunction · 0.85
AtomicAddFunction · 0.50
MinFunction · 0.50
loadMethod · 0.45
storeMethod · 0.45
GetMethod · 0.45
WaitMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected