X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker-benchmarks.git;a=blobdiff_plain;f=williams-queue%2Fwilliams-queue.h;h=36633db2b4a5d157c2a62284215a1c1a9a274d0a;hp=fdf8337ad3bd61beb7c8ebd9c1a502991d98b5b9;hb=12f92a94d28b2a674f5ec2c0b112fa654734f19d;hpb=c2ac1e3d5e63916c9f08a2847a9bc178040c82f5;ds=sidebyside diff --git a/williams-queue/williams-queue.h b/williams-queue/williams-queue.h index fdf8337..36633db 100644 --- a/williams-queue/williams-queue.h +++ b/williams-queue/williams-queue.h @@ -26,22 +26,7 @@ private: head.store(old_head->next); return old_head; } -public: - lock_free_queue(): - head(new node),tail(head.load()) - {} - // lock_free_queue(const lock_free_queue& other)=delete; - // lock_free_queue& operator=(const lock_free_queue& other)=delete; - ~lock_free_queue() - { - while(node* const old_head=head.load()) - { - head.store(old_head->next); - delete old_head; - } - } -private: struct counted_node_ptr { int external_count; @@ -66,8 +51,9 @@ private: new_count.internal_count=0; new_count.external_counters=2; count.store(new_count); - next.ptr=nullptr; - next.external_count=0; + + counted_node_ptr emptynode = {0, nullptr}; + next = emptynode; } void release_ref() { @@ -164,6 +150,23 @@ private: current_tail_ptr->release_ref(); } public: + lock_free_queue() + { + counted_node_ptr newnode = {0, new node}; + head = newnode; + tail = head.load(); + } + // lock_free_queue(const lock_free_queue& other)=delete; + // lock_free_queue& operator=(const lock_free_queue& other)=delete; + ~lock_free_queue() + { + while(node* const old_head=head.load()) + { + head.store(old_head->next); + delete old_head; + } + } + void push(T new_value) { std::unique_ptr new_data(new T(new_value));