MCPcopy Create free account
hub / github.com/arjunskumar/Robotics_CPP_Notes / pop

Method pop

capstone/sensor_pipeline.hpp:51–62  ·  view source on GitHub ↗

Consumer: pop with blocking wait (Module 08: std::optional)

Source from the content-addressed store, hash-verified

49
50 // Consumer: pop with blocking wait (Module 08: std::optional)
51 [[nodiscard]] std::optional<T> pop() {
52 std::unique_lock<std::mutex> lock(mux_);
53 cv_data_.wait(lock, [this] { return count_ > 0 || !active_; });
54 if (count_ == 0) return std::nullopt; // Shutdown signal
55
56 T item = buffer_[head_];
57 head_ = (head_ + 1) % N;
58 --count_;
59 lock.unlock();
60 cv_space_.notify_one();
61 return item;
62 }
63
64 void shutdown() {
65 {

Callers 2

consumerLoopMethod · 0.80
TESTFunction · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64