10 // Forward declaration
15 std::atomic<mcs_node *> next;
16 std::atomic<int> gate;
24 // C-callable interface
26 void mcs_lock(mcs_mutex *mutex, CGuard guard);
28 void mcs_unlock(mcs_mutex *mutex, CGuard guard);
32 // tail is null when lock is not held
33 std::atomic<mcs_node *> m_tail;
39 RL_ASSERT( m_tail.load() == NULL );
45 mcs_node m_node; // node held on the stack
47 // Call the wrapper (instrument every lock/unlock)
48 guard(mcs_mutex * t) : m_t(t) { mcs_lock(t, this); }
49 ~guard() { mcs_unlock(m_t, this); }
54 void unlock(guard * I);