MCPcopy Create free account
hub / github.com/Genivia/ugrep / dequeue

Method dequeue

src/ugrep.cpp:2130–2148  ·  view source on GitHub ↗

pop a job

Source from the content-addressed store, hash-verified

2128
2129 // pop a job
2130 void dequeue(Job& job)
2131 {
2132 while (empty())
2133 {
2134 // we must lock and wait until the buffer is not empty
2135 std::unique_lock<std::mutex> lock(queue_mutex);
2136 queue_data.wait(lock);
2137 lock.unlock();
2138 }
2139
2140 Job *next = head.load() + 1;
2141 if (next == &ring[DEFAULT_MAX_JOB_QUEUE_SIZE])
2142 next = ring;
2143
2144 job = *head.load();
2145 head.store(next);
2146 --todo;
2147 queue_full.notify_one();
2148 }
2149
2150 Job ring[DEFAULT_MAX_JOB_QUEUE_SIZE];
2151 std::atomic<Job*> head;

Callers 1

next_jobMethod · 0.80

Calls 1

noneMethod · 0.80

Tested by

no test coverage detected