17 #ifndef CYBER_BASE_UNBOUNDED_QUEUE_H_ 18 #define CYBER_BASE_UNBOUNDED_QUEUE_H_ 45 auto node =
new Node();
47 Node* old_tail = tail_.load();
50 if (tail_.compare_exchange_strong(old_tail, node)) {
51 old_tail->next = node;
60 Node* old_head = head_.load();
61 Node* head_next =
nullptr;
63 head_next = old_head->next;
65 if (head_next ==
nullptr) {
68 }
while (!head_.compare_exchange_strong(old_head, head_next));
69 *element = head_next->data;
75 size_t Size() {
return size_.load(); }
77 bool Empty() {
return size_.load() == 0; }
82 std::atomic<uint32_t> ref_count;
84 Node() { ref_count.store(2); }
86 ref_count.fetch_sub(1);
87 if (ref_count.load() == 0) {
94 auto node =
new Node();
101 auto ite = head_.load();
103 while (ite !=
nullptr) {
110 std::atomic<Node*> head_;
111 std::atomic<Node*> tail_;
112 std::atomic<size_t> size_;
119 #endif // CYBER_BASE_UNBOUNDED_QUEUE_H_ size_t Size()
Definition: unbounded_queue.h:75
~UnboundedQueue()
Definition: unbounded_queue.h:37
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
UnboundedQueue()
Definition: unbounded_queue.h:33
bool Empty()
Definition: unbounded_queue.h:77
void Clear()
Definition: unbounded_queue.h:39
UnboundedQueue & operator=(const UnboundedQueue &other)=delete
bool Dequeue(T *element)
Definition: unbounded_queue.h:59
void Enqueue(const T &element)
Definition: unbounded_queue.h:44
Definition: unbounded_queue.h:31