X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=spsc-queue%2Fqueue.h;fp=spsc-queue%2Fqueue.h;h=7a6f29e80c60bd6d9f9b0ef6e5571aae5501db4e;hb=91cb95bde87d2b7023fc2d2e344fba24e6dbca70;hp=d65477bf71d99f62edb54220cd2447b5611fcc52;hpb=fcf905f172a2b1f019e2b4e730b2628e487d2b56;p=model-checker-benchmarks.git diff --git a/spsc-queue/queue.h b/spsc-queue/queue.h index d65477b..7a6f29e 100644 --- a/spsc-queue/queue.h +++ b/spsc-queue/queue.h @@ -1,3 +1,5 @@ +#include + #include "eventcount.h" template @@ -7,21 +9,21 @@ public: spsc_queue() { node* n = RL_NEW node (); - head($) = n; - tail($) = n; + head = n; + tail = n; } ~spsc_queue() { - RL_ASSERT(head($) == tail($)); + RL_ASSERT(head == tail); RL_DELETE((node*)head($)); } void enqueue(T data) { node* n = RL_NEW node (data); - head($)->next($).store(n, std::memory_order_release); - head($) = n; + head($)->next.store(n, std::memory_order_release); + head = n; ec.signal_relaxed(); } @@ -62,12 +64,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; + tail = n; return data; } };