45 auto node =
new Node();
47 Node* old_tail = tail_.load();
50 if (tail_.compare_exchange_strong(old_tail, node)) {
51 old_tail->next = node;
60 Node* old_head = head_.load();
61 Node* head_next =
nullptr;
63 head_next = old_head->next;
65 if (head_next ==
nullptr) {
68 }
while (!head_.compare_exchange_strong(old_head, head_next));
69 *element = head_next->data;
75 size_t Size() {
return size_.load(); }
77 bool Empty() {
return size_.load() == 0; }
82 std::atomic<uint32_t> ref_count;
84 Node() { ref_count.store(2); }
86 ref_count.fetch_sub(1);
87 if (ref_count.load() == 0) {
94 auto node =
new Node();
101 auto ite = head_.load();
103 while (ite !=
nullptr) {
110 std::atomic<Node*> head_;
111 std::atomic<Node*> tail_;
112 std::atomic<size_t> size_;