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 38 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 31 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 64 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 76 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 135 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 152 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 81 of file OnOffNotifier.h.

References pipe_.

Referenced by wait().


Member Data Documentation

bool oasys::OnOffNotifier::waiter_ [protected]

Definition at line 84 of file OnOffNotifier.h.

Referenced by wait().

bool oasys::OnOffNotifier::quiet_ [protected]

Definition at line 85 of file OnOffNotifier.h.

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

SpinLock oasys::OnOffNotifier::notifier_lock_ [protected]

Definition at line 87 of file OnOffNotifier.h.

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

bool oasys::OnOffNotifier::active_ [protected]

Definition at line 88 of file OnOffNotifier.h.

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

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

Definition at line 89 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 Thu Jun 7 16:57:02 2007 for DTN Reference Implementation by  doxygen 1.5.1