X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=spsc-queue%2Fqueue.h;h=c77425f5b662f1de1982e9738ede23bcff4e4a07;hb=ff4cd01eb602228cbd4091539c3f9754cb946dda;hp=d65477bf71d99f62edb54220cd2447b5611fcc52;hpb=ced31653a84f29c3f236fb5976f1241262953914;p=model-checker-benchmarks.git diff --git a/spsc-queue/queue.h b/spsc-queue/queue.h index d65477b..c77425f 100644 --- a/spsc-queue/queue.h +++ b/spsc-queue/queue.h @@ -1,3 +1,6 @@ +#include +#include + #include "eventcount.h" template @@ -6,22 +9,22 @@ class spsc_queue public: spsc_queue() { - node* n = RL_NEW node (); - head($) = n; - tail($) = n; + node* n = new node (); + head = n; + tail = n; } ~spsc_queue() { - RL_ASSERT(head($) == tail($)); - RL_DELETE((node*)head($)); + RL_ASSERT(head == tail); + delete ((node*)head($)); } void enqueue(T data) { - node* n = RL_NEW node (data); - head($)->next($).store(n, std::memory_order_release); - head($) = n; + node* n = new node (data); + head($)->next.store(n, std::memory_order_release); + head = n; ec.signal_relaxed(); } @@ -49,9 +52,10 @@ private: rl::var data; node(T data = T()) - : next(0) - , data(data) - {} + : data(data) + { + next = 0; + } }; rl::var head; @@ -62,12 +66,12 @@ private: T try_dequeue() { node* t = tail($); - node* n = t->next($).load(std::memory_order_acquire); + node* n = t->next.load(std::memory_order_acquire); if (0 == n) return 0; T data = n->data($); - RL_DELETE(t); - tail($) = n; + delete (t); + tail = n; return data; } };