Class faiss::WorkerThread
-
class faiss::WorkerThread
Public Functions
-
WorkerThread()
-
~WorkerThread()
Stops and waits for the worker thread to exit, flushing all pending lambdas
-
void stop()
Request that the worker thread stop itself.
-
void waitForThreadExit()
Blocking waits in the current thread for the worker thread to stop
-
std::future<bool> add(std::function<void()> f)
Adds a lambda to run on the worker thread; returns a future that can be used to block on its completion. Future status is
true
if the lambda was run in the worker thread;false
if it was not run, because the worker thread is exiting or has exited.
Private Members
-
std::thread thread_
Thread that all queued lambdas are run on.
-
std::mutex mutex_
Mutex for the queue and exit status.
-
std::condition_variable monitor_
Monitor for the exit status and the queue.
-
bool wantStop_
Whether or not we want the thread to exit.
-
std::deque<std::pair<std::function<void()>, std::promise<bool>>> queue_
Queue of pending lambdas to call.
-
WorkerThread()