PopBack removes and returns the last elements in the queue.
| 100 | |
| 101 | // PopBack removes and returns the last elements in the queue. |
| 102 | Work PopBack() { |
| 103 | if (Empty()) return Work(); |
| 104 | EIGEN_MUTEX_LOCK lock(mutex_); |
| 105 | unsigned back = back_.load(std::memory_order_relaxed); |
| 106 | Elem* e = &array_[back & kMask]; |
| 107 | uint8_t s = e->state.load(std::memory_order_relaxed); |
| 108 | if (s != kReady || |
| 109 | !e->state.compare_exchange_strong(s, kBusy, std::memory_order_acquire)) |
| 110 | return Work(); |
| 111 | Work w = std::move(e->w); |
| 112 | e->state.store(kEmpty, std::memory_order_release); |
| 113 | back_.store(back + 1 + (kSize << 1), std::memory_order_relaxed); |
| 114 | return w; |
| 115 | } |
| 116 | |
| 117 | // PopBackHalf removes and returns half last elements in the queue. |
| 118 | // Returns number of elements removed. |
no test coverage detected