oasys::OnOffNotifier Class Reference

#include <OnOffNotifier.h>

Inheritance diagram for oasys::OnOffNotifier:

oasys::Logger List of all members.

Detailed Description

OnOffNotifier is a binary state synchronization object.

It has two states, signalled and not signalled. When a OnOffNotifier becomes active, threads that was blocked waiting for the OnOffNotifier becomes unblocked. Also, any subsequent calls to wait on an active OnOffNotifier returns immediately.

When inactive, threads block waiting for the OnOffNotifier.

Definition at line 59 of file OnOffNotifier.h.

Public Member Functions

 OnOffNotifier (const char *logpath=0, bool keep_quiet=true)
 Constructor that takes the logging path and an optional boolean to suppress all logging.
 ~OnOffNotifier ()
 Destructor.
bool wait (Lock *lock=0, int timeout=-1)
 Block the calling thread, pending a switch to the active state.
void signal ()
 Switch to active state.
void clear ()
 Clear the signaled state.
int read_fd ()
 
Returns:
the read side of the pipe


Protected Attributes

bool waiter_
bool quiet_
SpinLock notifier_lock_
bool active_
int pipe_ [2]


Constructor & Destructor Documentation

oasys::OnOffNotifier::OnOffNotifier ( const char *  logpath = 0,
bool  keep_quiet = true 
)

Constructor that takes the logging path and an optional boolean to suppress all logging.

Definition at line 52 of file OnOffNotifier.cc.

References errno, log_debug, oasys::Logger::logpath_, oasys::Logger::logpath_appendf(), oasys::Logger::logpathf(), pipe_, quiet_, and oasys::IO::set_nonblocking().

oasys::OnOffNotifier::~OnOffNotifier (  ) 

Destructor.

Definition at line 85 of file OnOffNotifier.cc.

References log_debug, pipe_, and quiet_.


Member Function Documentation

bool oasys::OnOffNotifier::wait ( Lock lock = 0,
int  timeout = -1 
)

Block the calling thread, pending a switch to the active state.

Parameters:
lock If a lock is passed in, wait() will unlock the lock before the thread blocks and re-take it when the end unblocks.
timeout Timeout in milliseconds.
Returns true if the thread was notified, false if a timeout occurred.

Definition at line 97 of file OnOffNotifier.cc.

References active_, errno, oasys::IOTIMEOUT, oasys::Lock::lock(), oasys::SpinLock::lock(), log_debug, oasys::Logger::logpath_, notifier_lock_, oasys::IO::poll_single(), quiet_, read_fd(), oasys::Lock::unlock(), oasys::SpinLock::unlock(), and waiter_.

Referenced by oasys::TimerThread::run().

void oasys::OnOffNotifier::signal (  ) 

Switch to active state.

Please note that there is not guarrantee that when signal_OnOffNotifier returns, all of the threads waiting on the OnOffNotifier have been released.

Definition at line 156 of file OnOffNotifier.cc.

References active_, ASSERT, ExamineDump::l, notifier_lock_, and pipe_.

Referenced by oasys::TimerSystem::post_signal(), and oasys::TimerSystem::schedule_at().

void oasys::OnOffNotifier::clear (  ) 

Clear the signaled state.

Definition at line 173 of file OnOffNotifier.cc.

References active_, ASSERT, ExamineDump::l, notifier_lock_, and pipe_.

int oasys::OnOffNotifier::read_fd (  )  [inline]

Returns:
the read side of the pipe

Definition at line 102 of file OnOffNotifier.h.

References pipe_.

Referenced by wait().


Member Data Documentation

bool oasys::OnOffNotifier::waiter_ [protected]

Definition at line 105 of file OnOffNotifier.h.

Referenced by wait().

bool oasys::OnOffNotifier::quiet_ [protected]

Definition at line 106 of file OnOffNotifier.h.

Referenced by OnOffNotifier(), wait(), and ~OnOffNotifier().

SpinLock oasys::OnOffNotifier::notifier_lock_ [protected]

Definition at line 108 of file OnOffNotifier.h.

Referenced by clear(), signal(), and wait().

bool oasys::OnOffNotifier::active_ [protected]

Definition at line 109 of file OnOffNotifier.h.

Referenced by clear(), signal(), and wait().

int oasys::OnOffNotifier::pipe_[2] [protected]

Definition at line 110 of file OnOffNotifier.h.

Referenced by clear(), OnOffNotifier(), read_fd(), signal(), and ~OnOffNotifier().


The documentation for this class was generated from the following files:
Generated on Fri Dec 22 14:48:07 2006 for DTN Reference Implementation by  doxygen 1.5.1