MCPcopy Create free account
hub / github.com/GNOME/gjs / lock

Method lock

gi/toggle.cpp:28–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void ToggleQueue::lock() {
29 auto holding_thread = std::thread::id();
30 auto current_thread = std::this_thread::get_id();
31
32 while (!m_holder.compare_exchange_weak(holding_thread, current_thread,
33 std::memory_order_acquire)) {
34 // In case the current thread is holding the lock, we can just try
35 // again, checking if this is still true and in case continue
36 if (holding_thread != current_thread)
37 holding_thread = std::thread::id();
38 }
39
40 m_holder_ref_count++;
41}
42
43void ToggleQueue::maybe_unlock() {
44 g_assert(owns_lock() && "Nothing to unlock here");

Callers 1

LockedMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected