#include <Timer.h>
Definition at line 90 of file Timer.h.
Public Member Functions | |
void | schedule_at (struct timeval *when, Timer *timer) |
void | schedule_in (int milliseconds, Timer *timer) |
void | schedule_immediate (Timer *timer) |
bool | cancel (Timer *timer) |
void | add_sighandler (int sig, sighandlerfn_t *handler) |
Hook to use the timer thread to safely handle a signal. | |
int | run_expired_timers () |
Run any timers that have expired. | |
OnOffNotifier * | notifier () |
Accessor for the notifier that indicates if another thread put a timer on the queue. | |
Static Public Member Functions | |
static void | post_signal (int sig) |
Hook called from an the actual signal handler that notifies the timer system thread to call the signal handler function. | |
Private Types | |
typedef std::priority_queue < Timer *, std::vector< Timer * >, TimerCompare > | TimerQueue |
Private Member Functions | |
TimerSystem () | |
virtual | ~TimerSystem () |
void | pop_timer (const struct timeval &now) |
void | handle_signals () |
Private Attributes | |
sighandlerfn_t * | handlers_ [NSIG] |
KNOWN ISSUE: Signal handling has race conditions - but it's not worth the trouble to fix. | |
bool | signals_ [NSIG] |
which signals have fired | |
bool | sigfired_ |
boolean to check if any fired | |
SpinLock * | system_lock_ |
OnOffNotifier | notifier_ |
TimerQueue | timers_ |
Friends | |
class | Singleton< TimerSystem > |
typedef std::priority_queue<Timer*, std::vector<Timer*>, TimerCompare> oasys::TimerSystem::TimerQueue [private] |
oasys::TimerSystem::TimerSystem | ( | ) | [private] |
oasys::TimerSystem::~TimerSystem | ( | ) | [private, virtual] |
void oasys::TimerSystem::schedule_at | ( | struct timeval * | when, | |
Timer * | timer | |||
) |
Definition at line 58 of file Timer.cc.
References oasys::Timer::cancelled_, dtnsim::gettimeofday(), ExamineDump::l, log_debug, notifier_, oasys::Timer::pending_, oasys::OnOffNotifier::signal(), system_lock_, timers_, TIMEVAL_DIFF_MSEC, and oasys::Timer::when_.
Referenced by schedule_immediate(), and schedule_in().
void oasys::TimerSystem::schedule_in | ( | int | milliseconds, | |
Timer * | timer | |||
) |
void oasys::TimerSystem::schedule_immediate | ( | Timer * | timer | ) |
Definition at line 119 of file Timer.cc.
References oasys::Timer::cancelled_, ExamineDump::l, oasys::Timer::pending_, and system_lock_.
void oasys::TimerSystem::add_sighandler | ( | int | sig, | |
sighandlerfn_t * | handler | |||
) |
Hook to use the timer thread to safely handle a signal.
Definition at line 149 of file Timer.cc.
References handlers_, log_debug, and post_signal().
void oasys::TimerSystem::post_signal | ( | int | sig | ) | [static] |
Hook called from an the actual signal handler that notifies the timer system thread to call the signal handler function.
Definition at line 137 of file Timer.cc.
References notifier_, sigfired_, oasys::OnOffNotifier::signal(), and signals_.
Referenced by add_sighandler().
int oasys::TimerSystem::run_expired_timers | ( | ) |
Run any timers that have expired.
Returns the interval in milliseconds until the next timer that needs to fire.
Definition at line 213 of file Timer.cc.
References ASSERT, dtnsim::gettimeofday(), handle_signals(), ExamineDump::l, log_debug, pop_timer(), system_lock_, timers_, TIMEVAL_DIFF_MSEC, TIMEVAL_LT, and oasys::Timer::when_.
Referenced by oasys::TimerThread::run(), and dtn::BundleDaemon::run().
OnOffNotifier* oasys::TimerSystem::notifier | ( | ) | [inline] |
Accessor for the notifier that indicates if another thread put a timer on the queue.
Definition at line 119 of file Timer.h.
References notifier_.
Referenced by oasys::TimerThread::run(), and dtn::BundleDaemon::run().
void oasys::TimerSystem::pop_timer | ( | const struct timeval & | now | ) | [private] |
Definition at line 158 of file Timer.cc.
References ASSERT, oasys::Timer::DELETE_ON_CANCEL, oasys::Lock::is_locked_by_me(), log_debug, log_warn, system_lock_, timers_, and TIMEVAL_DIFF_MSEC.
Referenced by run_expired_timers().
void oasys::TimerSystem::handle_signals | ( | ) | [private] |
friend class Singleton< TimerSystem > [friend] |
sighandlerfn_t* oasys::TimerSystem::handlers_[NSIG] [private] |
KNOWN ISSUE: Signal handling has race conditions - but it's not worth the trouble to fix.
handlers for signals
Definition at line 130 of file Timer.h.
Referenced by add_sighandler(), handle_signals(), and TimerSystem().
bool oasys::TimerSystem::signals_[NSIG] [private] |
which signals have fired
Definition at line 131 of file Timer.h.
Referenced by handle_signals(), post_signal(), and TimerSystem().
bool oasys::TimerSystem::sigfired_ [private] |
boolean to check if any fired
Definition at line 132 of file Timer.h.
Referenced by handle_signals(), post_signal(), and TimerSystem().
SpinLock* oasys::TimerSystem::system_lock_ [private] |
Definition at line 134 of file Timer.h.
Referenced by cancel(), pop_timer(), run_expired_timers(), and schedule_at().
OnOffNotifier oasys::TimerSystem::notifier_ [private] |
TimerQueue oasys::TimerSystem::timers_ [private] |
Definition at line 136 of file Timer.h.
Referenced by pop_timer(), run_expired_timers(), schedule_at(), and ~TimerSystem().