MCPcopy Create free account
hub / github.com/MaskRay/ccls / tryPopFront

Method tryPopFront

src/threaded_queue.hh:140–153  ·  view source on GitHub ↗

Get the first element from the queue without blocking. Returns a null value if the queue is empty.

Source from the content-addressed store, hash-verified

138 // Get the first element from the queue without blocking. Returns a null
139 // value if the queue is empty.
140 std::optional<T> tryPopFront() {
141 std::lock_guard<std::mutex> lock(mutex_);
142 auto execute = [&](std::deque<T> *q) {
143 auto val = std::move(q->front());
144 q->pop_front();
145 --total_count_;
146 return val;
147 };
148 if (priority_.size())
149 return execute(&priority_);
150 if (queue_.size())
151 return execute(&queue_);
152 return std::nullopt;
153 }
154
155 template <typename Fn> void apply(Fn fn) {
156 std::lock_guard<std::mutex> lock(mutex_);

Callers 2

indexer_ParseFunction · 0.80
mainLoopFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected