Pushes the node onto the queue's head. This is O(1).
| 112 | |
| 113 | /// Pushes the node onto the queue's head. This is O(1). |
| 114 | void PushFront(T* n) { |
| 115 | Node* node = (Node*)n; |
| 116 | DCHECK(node->next == nullptr); |
| 117 | DCHECK(node->prev == nullptr); |
| 118 | DCHECK(node->parent_queue == nullptr); |
| 119 | node->parent_queue = this; |
| 120 | { |
| 121 | std::lock_guard<LockType> lock(lock_); |
| 122 | if (head_ != nullptr) head_->prev = node; |
| 123 | node->next = head_; |
| 124 | head_ = node; |
| 125 | if (tail_ == nullptr) tail_ = node; |
| 126 | ++size_; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /// Dequeues an element from the queue's head. Returns nullptr if the queue |
| 131 | /// is empty. This is O(1). |
no outgoing calls