4 #if __GNUC__ == 4 && __GNUC_MINOR__ == 4
5 # include <cstdatomic> // <atomic> is named <cstdatomic> in gcc 4.4
7 template<typename _Tp> // fix missing definition in gcc 4.4
9 atomic<_Tp*>::store(_Tp* __v, memory_order __m) volatile
10 { atomic_address::store(__v, __m); }
21 node* n = new node(NULL, NULL);
28 node* n = head.load();
38 return head.load() == tail.load();
41 // size() is not not thread-safe
45 for (node* n = head.load()->next; n != NULL; n = n->next)
50 bool push(const T& val)
52 node* old_tail = tail.load();
53 node* n = new node(val, NULL);
56 return (old_tail == head.load());
61 node* old_head = head.load();
62 if (old_head == tail.load()) { // empty?
65 node* new_head = old_head->next;
68 res = new_head->value;
75 node(const T& v, node* n): value(v), next(n) { }
80 std::atomic<node*> head;
81 std::atomic<node*> tail;
84 #endif // !SYNC_QUEUE_H