Nebula
|
#include <linuxcompletioncounter.h>
Block a thread until count reaches 0.
(C) 2010 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file
Public Member Functions | |
LinuxCompletionCounter () | |
constructor | |
~LinuxCompletionCounter () | |
destructor | |
void | Reset (int count) |
reset the counter, call from main thread | |
bool | Decrement (int num) |
decrement the counter, call from worker threads, return true if count has reached zero | |
void | Wait () |
wait until counter has reached 0, call from main thread or worker threads | |
bool | Peek () |
check if the counter has reached 0 | |
Private Attributes | |
volatile int | curCount |
pthread_cond_t | completionEvent |
|
inline |
constructor
|
inline |
destructor
|
inline |
decrement the counter, call from worker threads, return true if count has reached zero
This method is called from several worker thread to decrement the counter.
When the counter reaches 0, the completionEvent will be signalled and the method will return true, otherwise false.
|
inline |
check if the counter has reached 0
Return true if the completion counter has reached 0.
|
inline |
reset the counter, call from main thread
Reset the counter.
Call this method from the main thread before work items are pushed to the worker threads. It is safe to use non-thread-safe functions here.
|
inline |
wait until counter has reached 0, call from main thread or worker threads
This method may be called by either one of the worker threads, or the main thread to wait for the completion of an event.
Any number of threads may wait for completion.
|
private |
|
private |