MCPcopy Create free account
hub / github.com/apache/impala / WorkerThread

Method WorkerThread

be/src/util/thread-pool.h:162–176  ·  view source on GitHub ↗

Driver method for each thread in the pool. Continues to read work from the queue until the pool is shutdown.

Source from the content-addressed store, hash-verified

160 /// Driver method for each thread in the pool. Continues to read work from the queue
161 /// until the pool is shutdown.
162 void WorkerThread(int thread_id) {
163 while (!IsShutdown()) {
164 T workitem;
165 if (work_queue_.BlockingGet(&workitem)) {
166 work_function_(thread_id, workitem);
167 }
168 if (work_queue_.Size() == 0) {
169 /// Take lock to ensure that DrainAndShutdown() cannot be between checking
170 /// GetSize() and wait()'ing when the condition variable is notified.
171 /// (It will hang if we notify right before calling wait().)
172 std::unique_lock<std::mutex> l(lock_);
173 empty_cv_.NotifyAll();
174 }
175 }
176 }
177
178 /// Returns value of shutdown_ under a lock, forcing visibility to threads in the pool.
179 bool IsShutdown() {

Callers

nothing calls this directly

Calls 3

NotifyAllMethod · 0.80
BlockingGetMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected