MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / PopBack

Method PopBack

include/Eigen/Eigen/src/ThreadPool/RunQueue.h:102–115  ·  view source on GitHub ↗

PopBack removes and returns the last elements in the queue.

Source from the content-addressed store, hash-verified

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.

Callers 2

StealMethod · 0.80
WaitForWorkMethod · 0.80

Calls 2

loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected