#include <OnOffNotifier.h>
Inheritance diagram for oasys::OnOffNotifier:
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 () |
| |
Protected Attributes | |
bool | waiter_ |
bool | quiet_ |
SpinLock | notifier_lock_ |
bool | active_ |
int | pipe_ [2] |
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 | ( | ) |
Block the calling thread, pending a switch to the active state.
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. |
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] |
Definition at line 102 of file OnOffNotifier.h.
References pipe_.
Referenced by wait().
bool oasys::OnOffNotifier::waiter_ [protected] |
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] |
bool oasys::OnOffNotifier::active_ [protected] |
int oasys::OnOffNotifier::pipe_[2] [protected] |
Definition at line 110 of file OnOffNotifier.h.
Referenced by clear(), OnOffNotifier(), read_fd(), signal(), and ~OnOffNotifier().