42 tt_axiom(semaphore.
load() <= 2);
45 uint32_t expected = 0;
47 [[unlikely]] lock_contented(expected);
49#if TT_BUILD_TYPE == TT_BT_DEBUG
50 locking_thread = current_thread_id();
52 tt_axiom(semaphore.
load() <= 2);
63 tt_axiom(semaphore.
load() <= 2);
66 uint32_t expected = 0;
68 tt_axiom(semaphore.
load() <= 2);
69 [[unlikely]]
return false;
71#if TT_BUILD_TYPE == TT_BT_DEBUG
72 locking_thread = current_thread_id();
74 tt_axiom(semaphore.
load() <= 2);
78 void unlock() noexcept {
79 tt_axiom(semaphore.
load() <= 2);
81 if (semaphore.
fetch_sub(1, std::memory_order::relaxed) != 1) {
82 [[unlikely]] semaphore.
store(0, std::memory_order::release);
84 semaphore.notify_one();
86 atomic_thread_fence(std::memory_order::release);
88#if TT_BUILD_TYPE == TT_BT_DEBUG
92 tt_axiom(semaphore.
load() <= 2);
104#if TT_BUILD_TYPE == TT_BT_DEBUG
105 thread_id locking_thread;
108 tt_no_inline
void lock_contented(uint32_t expected)
noexcept
110 tt_axiom(semaphore.
load() <= 2);
113 ttlet should_wait = expected == 2;
118#if TT_BUILD_TYPE == TT_BT_DEBUG
121 tt_assert(locking_thread != current_thread_id());
123 tt_axiom(semaphore.
load() <= 2);
127 tt_axiom(semaphore.
load() <= 2);