osgEarth 2.1.1
Public Member Functions | Protected Attributes

osgEarth::Threading::MultiEvent Class Reference

List of all members.

Public Member Functions

 MultiEvent (int num=1)
 ~MultiEvent ()
bool wait ()
bool waitAndReset ()
void notify ()
void reset (int num=0)

Protected Attributes

OpenThreads::Mutex _m
OpenThreads::Condition _cond
int _set
int _num

Detailed Description

Same as an Event, but waits on multiple notifications before releasing its wait.

Definition at line 99 of file ThreadingUtils.


Constructor & Destructor Documentation

osgEarth::Threading::MultiEvent::MultiEvent ( int  num = 1) [inline]

Definition at line 102 of file ThreadingUtils.

: _set( num ), _num(num)  { }
osgEarth::Threading::MultiEvent::~MultiEvent ( ) [inline]

Definition at line 104 of file ThreadingUtils.

                      {
            reset();
            for( int i=0; i<255; ++i ) // workaround buggy broadcast
                _cond.signal();
        }

Here is the call graph for this function:


Member Function Documentation

void osgEarth::Threading::MultiEvent::notify ( ) [inline]

Definition at line 128 of file ThreadingUtils.

                             {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _m );
            if ( _set > 0 )
                --_set;
            if ( _set == 0 )
                _cond.broadcast(); // possible deadlock before OSG r10457 on windows
            //_cond.signal();
        }

Here is the caller graph for this function:

void osgEarth::Threading::MultiEvent::reset ( int  num = 0) [inline]

Definition at line 137 of file ThreadingUtils.

                                        {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _m );
            if ( num > 0 ) _num = num;
            _set = _num;
        }

Here is the caller graph for this function:

bool osgEarth::Threading::MultiEvent::wait ( ) [inline]

Definition at line 110 of file ThreadingUtils.

                           {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _m );
            while( _set > 0 )
                if ( _cond.wait( &_m ) != 0 )
                    return false;
            return true;
        }

Here is the caller graph for this function:

bool osgEarth::Threading::MultiEvent::waitAndReset ( ) [inline]

waits on a signal, and then automatically resets it before returning.

Definition at line 119 of file ThreadingUtils.

                                   {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _m );
            while( _set > 0 )
                if ( _cond.wait( &_m ) != 0 )
                    return false;
            _set = _num;
            return true;
        }

Member Data Documentation

OpenThreads::Condition osgEarth::Threading::MultiEvent::_cond [protected]

Definition at line 145 of file ThreadingUtils.

OpenThreads::Mutex osgEarth::Threading::MultiEvent::_m [protected]

Definition at line 144 of file ThreadingUtils.

Definition at line 146 of file ThreadingUtils.

Definition at line 146 of file ThreadingUtils.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines