Commit b82b54ba authored by Maged Michael's avatar Maged Michael Committed by Facebook Github Bot

UnboundedQueue: Use hazptr_obj_batch.

Summary: Use hazptr_obj_batch to ensure that interrelated retired segments are checked together against hazard pointers.

Reviewed By: djwatson

Differential Revision: D10148259

fbshipit-source-id: eeaa127d808c68fcd12d7dd8ef25a4fdb870084f
parent 65f490e7
......@@ -233,7 +233,10 @@ class UnboundedQueue {
struct Consumer {
Atom<Segment*> head;
Atom<Ticket> ticket;
explicit Consumer(Segment* s) : head(s), ticket(0) {}
hazptr_obj_batch<Atom> batch;
explicit Consumer(Segment* s) : head(s), ticket(0) {
s->set_batch_no_tag(&batch); // defined in hazptr_obj
}
};
struct Producer {
Atom<Segment*> tail;
......@@ -252,6 +255,7 @@ class UnboundedQueue {
/** destructor */
~UnboundedQueue() {
cleanUpRemainingItems();
c_.batch.shutdown_and_reclaim();
reclaimRemainingSegments();
}
......@@ -547,6 +551,7 @@ class UnboundedQueue {
Segment* allocNextSegment(Segment* s) {
auto t = s->minTicket() + SegmentSize;
Segment* next = new Segment(t);
next->set_batch_no_tag(&c_.batch); // defined in hazptr_obj
next->acquire_ref_safe(); // defined in hazptr_obj_base_linked
if (!s->casNextSegment(next)) {
delete next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment