MCPcopy Create free account
hub / github.com/apache/brpc / push

Method push

src/bthread/work_stealing_queue.h:72–81  ·  view source on GitHub ↗

Push an item into the queue. Returns true on pushed. May run in parallel with steal(). Never run in parallel with pop() or another push().

Source from the content-addressed store, hash-verified

70 // May run in parallel with steal().
71 // Never run in parallel with pop() or another push().
72 bool push(const T& x) {
73 const size_t b = _bottom.load(butil::memory_order_relaxed);
74 const size_t t = _top.load(butil::memory_order_acquire);
75 if (b >= t + _capacity) { // Full queue.
76 return false;
77 }
78 _buffer[b & (_capacity - 1)] = x;
79 _bottom.store(b + 1, butil::memory_order_release);
80 return true;
81 }
82
83 // Pop an item from the queue.
84 // Returns true on popped and the item is written to `val'.

Callers

nothing calls this directly

Calls 2

loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected