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

Method PushBack

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

PushBack adds w at the end of the queue. If queue is full returns w, otherwise returns default-constructed Work.

Source from the content-addressed store, hash-verified

84 // PushBack adds w at the end of the queue.
85 // If queue is full returns w, otherwise returns default-constructed Work.
86 Work PushBack(Work w) {
87 EIGEN_MUTEX_LOCK lock(mutex_);
88 unsigned back = back_.load(std::memory_order_relaxed);
89 Elem* e = &array_[(back - 1) & kMask];
90 uint8_t s = e->state.load(std::memory_order_relaxed);
91 if (s != kEmpty ||
92 !e->state.compare_exchange_strong(s, kBusy, std::memory_order_acquire))
93 return w;
94 back = ((back - 1) & kMask2) | (back & ~kMask2);
95 back_.store(back, std::memory_order_relaxed);
96 e->w = std::move(w);
97 e->state.store(kReady, std::memory_order_release);
98 return Work();
99 }
100
101 // PopBack removes and returns the last elements in the queue.
102 Work PopBack() {

Callers 1

ScheduleWithHintMethod · 0.80

Calls 2

loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected