11 This ticket lock implementation is derived from the original Mellor-Crummey
12 & Scott paper <Algorithms for Scalable Synchronization on SharedMemory
13 Multiprocessors> in 1991. It assumes that the ticket and turn counter are
14 large enough to accommodate the maximum number of simultaneous requests for
19 ticket.store(0, std::memory_order_relaxed);
20 turn.store(0, std::memory_order_relaxed);
24 // First grab a ticket
25 unsigned my_ticket = ticket.fetch_add(1, std::memory_order_relaxed);
26 // Spinning for my turn
29 unsigned my_turn = turn.load(std::memory_order_acquire);
30 if (my_turn == my_ticket) {
40 unsigned my_turn = turn.load(std::memory_order_relaxed);
41 turn.store(my_turn + 1, std::memory_order_release);
45 std::atomic_uint ticket;
46 std::atomic_uint turn;
49 } // namespace cds_others