OpendTect-6_4  6.4
Public Member Functions | Protected Attributes | List of all members
Threads::ConditionVar Class Reference

Is an object that faciliates many threads to wait for something to happen. More...

Inheritance diagram for Threads::ConditionVar:
[legend]

Public Member Functions

 ConditionVar ()
 
 ConditionVar (const ConditionVar &)
 
 ~ConditionVar ()
 
void wait ()
 
bool wait (unsigned long timeout)
 
void signal (bool all)
 
- Public Member Functions inherited from Threads::Mutex
 Mutex (bool recursive=false)
 
 Mutex (const Mutex &)
 
virtual ~Mutex ()
 
void lock ()
 
void unLock ()
 
bool tryLock ()
 
int getCount () const
 

Protected Attributes

::QWaitCondition * cond_
 
- Protected Attributes inherited from Threads::Mutex
::QMutex * qmutex_
 
const void * lockingthread_
 Only set in debug-mode. More...
 
int count_
 Only set in debug-mode. More...
 

Detailed Description

Is an object that faciliates many threads to wait for something to happen.

Usage:

From the working thread

  1. lock() You will now be the only one allowed to check weather condition is true (e.g. if new work has arrived).
  2. Check condition. If false, call wait(). You will now sleep until someone calls signal(); If you are awakened, check the condition again and go back to sleep if it is false.
  3. If condition is true, unLock() and start working. When finished working go back to 1.

It is wise to put an exit flag in the loop, so it's possible to say that we are about to quit.

From the manager: When you want to change the condition:

  1. lock
  2. set condition (e.g. add more work)
  3. signal
  4. unLock

Constructor & Destructor Documentation

Threads::ConditionVar::ConditionVar ( )
Threads::ConditionVar::ConditionVar ( const ConditionVar )
Threads::ConditionVar::~ConditionVar ( )

Member Function Documentation

void Threads::ConditionVar::signal ( bool  all)

If all is true, all threads that have called wait() will be Notified about the signal. If all is false, only one thread will respond.

void Threads::ConditionVar::wait ( )
bool Threads::ConditionVar::wait ( unsigned long  timeout)
Parameters
timeoutis in milliseconds.
Return values
falseif timeout was hit

Member Data Documentation

:: QWaitCondition* Threads::ConditionVar::cond_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019