| 43 | } |
| 44 | |
| 45 | void 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 | |
| 59 | void NPrivate::UnlockRecursive(std::atomic<size_t>& lock) noexcept { |
| 60 | Y_ABORT_UNLESS(lock.load(std::memory_order_acquire) == MyThreadId(), "unlock from another thread?!?!"); |
nothing calls this directly
no test coverage detected