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

Method LockRecursive

util/generic/singleton.cpp:45–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void NPrivate::LockRecursive(std::atomic<size_t>& lock) noexcept {
46 const size_t id = MyThreadId();
47
48 Y_ABORT_UNLESS(lock.load(std::memory_order_acquire) != id, "recursive singleton initialization");
49
50 if (!MyAtomicTryLock(lock, id)) {
51 TSpinWait sw;
52
53 do {
54 sw.Sleep();
55 } while (!MyAtomicTryAndTryLock(lock, id));
56 }
57}
58
59void NPrivate::UnlockRecursive(std::atomic<size_t>& lock) noexcept {
60 Y_ABORT_UNLESS(lock.load(std::memory_order_acquire) == MyThreadId(), "unlock from another thread?!?!");

Callers

nothing calls this directly

Calls 5

MyThreadIdFunction · 0.85
MyAtomicTryLockFunction · 0.85
MyAtomicTryAndTryLockFunction · 0.85
loadMethod · 0.45
SleepMethod · 0.45

Tested by

no test coverage detected