Nebula
Loading...
Searching...
No Matches
Linux::LinuxCompletionCounter Class Reference

#include <linuxcompletioncounter.h>

Detailed Description

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
 

Constructor & Destructor Documentation

◆ LinuxCompletionCounter()

Linux::LinuxCompletionCounter::LinuxCompletionCounter ( )
inline

constructor

◆ ~LinuxCompletionCounter()

Linux::LinuxCompletionCounter::~LinuxCompletionCounter ( )
inline

destructor

Member Function Documentation

◆ Decrement()

bool Linux::LinuxCompletionCounter::Decrement ( int num)
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.

◆ Peek()

bool Linux::LinuxCompletionCounter::Peek ( )
inline

check if the counter has reached 0

Return true if the completion counter has reached 0.

◆ Reset()

void Linux::LinuxCompletionCounter::Reset ( int count)
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.

◆ Wait()

void Linux::LinuxCompletionCounter::Wait ( )
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.

Member Data Documentation

◆ completionEvent

pthread_cond_t Linux::LinuxCompletionCounter::completionEvent
private

◆ curCount

volatile int Linux::LinuxCompletionCounter::curCount
private

The documentation for this class was generated from the following file: