MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / pop

Method pop

tests/relacy/relacy/example/stack/stack.cpp:29–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 int pop()
30 {
31 node* n = head_.load(rl::memory_order_relaxed);
32 for (;;)
33 {
34 if (0 == n)
35 break;
36 node* next = n->next_.load(rl::memory_order_relaxed);
37 if (head_.compare_exchange_weak(n, next, rl::memory_order_acquire))
38 break;
39 }
40 if (n)
41 {
42 int data = n->data_($);
43 delete n;
44 return data;
45 }
46 else
47 {
48 return 0;
49 }
50 }
51
52private:
53 struct node

Callers 1

threadMethod · 0.45

Calls 2

loadMethod · 0.45
compare_exchange_weakMethod · 0.45

Tested by

no test coverage detected