X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/db665945760baeb8f0d50f663db8caeede59697c..4dc6e5f4f7bab0fa256fc11a74eddbac33d80f16:/sync_queue.h diff --git a/sync_queue.h b/sync_queue.h index 8888548..357a72d 100644 --- a/sync_queue.h +++ b/sync_queue.h @@ -3,6 +3,12 @@ #if __GNUC__ == 4 && __GNUC_MINOR__ == 4 # include // is named in gcc 4.4 + +template // fix missing definition in gcc 4.4 +void +atomic<_Tp*>::store(_Tp* __v, memory_order __m) volatile +{ atomic_address::store(__v, __m); } + #else # include #endif @@ -12,9 +18,9 @@ class sync_queue { 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() @@ -44,9 +50,9 @@ public: 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()); } @@ -57,7 +63,7 @@ public: 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; @@ -66,7 +72,7 @@ public: 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; };