osgEarth 2.1.1
Public Member Functions | Protected Attributes

osgEarth::Threading::Event Class Reference

List of all members.

Public Member Functions

 Event ()
 ~Event ()
bool wait ()
bool waitAndReset ()
void set ()
void reset ()
bool isSet () const

Protected Attributes

OpenThreads::Mutex _m
OpenThreads::Condition _cond
bool _set

Detailed Description

Event with a toggled signal state.

Definition at line 44 of file ThreadingUtils.


Constructor & Destructor Documentation

osgEarth::Threading::Event::Event ( ) [inline]

Definition at line 47 of file ThreadingUtils.

: _set( false ) { }
osgEarth::Threading::Event::~Event ( ) [inline]

Definition at line 49 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

bool osgEarth::Threading::Event::isSet ( ) const [inline]

Definition at line 88 of file ThreadingUtils.

                                  {
            return _set;
        }

Here is the caller graph for this function:

void osgEarth::Threading::Event::reset ( ) [inline]

Definition at line 83 of file ThreadingUtils.

                            {
            OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _m );
            _set = false;
        }

Here is the caller graph for this function:

void osgEarth::Threading::Event::set ( ) [inline]

Definition at line 74 of file ThreadingUtils.

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

Here is the caller graph for this function:

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

Definition at line 55 of file ThreadingUtils.

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

Here is the caller graph for this function:

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

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

Definition at line 61 of file ThreadingUtils.

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

Member Data Documentation

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

Definition at line 94 of file ThreadingUtils.

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

Definition at line 93 of file ThreadingUtils.

Definition at line 95 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