#if __GNUC__ == 4 && __GNUC_MINOR__ == 4
# include <cstdatomic> // <atomic> is named <cstdatomic> in gcc 4.4
+
+template<typename _Tp> // fix missing definition in gcc 4.4
+void
+atomic<_Tp*>::store(_Tp* __v, memory_order __m) volatile
+{ atomic_address::store(__v, __m); }
+
#else
# include <atomic>
#endif
public:
sync_queue()
{
- node* n = new node(NULL, NULL);
- std::atomic_store(&head, n); // head.store(n);
- std::atomic_store(&tail, n); // tail.store(n);
+ node* n = new node(NULL);
+ head.store(n);
+ tail.store(n);
}
~sync_queue()
bool push(const T& val)
{
node* old_tail = tail.load();
- node* n = new node(val, NULL);
+ node* n = new node(val);
old_tail->next = n;
- std::atomic_store(&tail, n); // tail.store(n);
+ tail.store(n);
return (old_tail == head.load());
}
return false;
} else {
node* new_head = old_head->next;
- std::atomic_store(&head, new_head); // head.store(new_head);
+ head.store(new_head);
delete old_head;
res = new_head->value;
return true;
private:
struct node {
- node(const T& v, node* n): value(v), next(n) { }
+ node(const T& v): value(v), next(NULL) { }
T value;
node* next;
};