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

Method PopFront

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

PopFront removes and returns the first element in the queue. If the queue was empty returns default-constructed Work.

Source from the content-addressed store, hash-verified

68 // PopFront removes and returns the first element in the queue.
69 // If the queue was empty returns default-constructed Work.
70 Work PopFront() {
71 unsigned front = front_.load(std::memory_order_relaxed);
72 Elem* e = &array_[(front - 1) & kMask];
73 uint8_t s = e->state.load(std::memory_order_relaxed);
74 if (s != kReady ||
75 !e->state.compare_exchange_strong(s, kBusy, std::memory_order_acquire))
76 return Work();
77 Work w = std::move(e->w);
78 e->state.store(kEmpty, std::memory_order_release);
79 front = ((front - 1) & kMask2) | (front & ~kMask2);
80 front_.store(front, std::memory_order_relaxed);
81 return w;
82 }
83
84 // PushBack adds w at the end of the queue.
85 // If queue is full returns w, otherwise returns default-constructed Work.

Callers 1

WorkerLoopMethod · 0.80

Calls 2

loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected