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

Method Acquire

util/system/spinlock.h:98–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96 using TSpinLockBase::TSpinLockBase;
97
98 void Acquire() noexcept {
99 intptr_t zero = 0;
100 if (Val_.compare_exchange_strong(zero, 1)) {
101 return;
102 }
103
104 TSpinWait sw;
105
106 for (;;) {
107 zero = 0;
108 if (Val_.load(std::memory_order_acquire) == 0 &&
109 Val_.compare_exchange_strong(zero, 1)) {
110 break;
111 }
112 sw.Sleep();
113 }
114 }
115
116 inline void lock() noexcept {
117 Acquire();

Callers

nothing calls this directly

Calls 3

loadMethod · 0.45
SleepMethod · 0.45

Tested by

no test coverage detected