oasys::TimerSystem Class Reference

#include <Timer.h>

Inheritance diagram for oasys::TimerSystem:

oasys::Logger List of all members.

Detailed Description

The main Timer system implementation that needs to be driven by a thread, such as the TimerThread class defined below.

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.
OnOffNotifiernotifier ()
 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_thandlers_ [NSIG]
 KNOWN ISSUE: Signal handling has race conditions - but it's not worth the trouble to fix. handlers for signals.
bool signals_ [NSIG]
 which signals have fired
bool sigfired_
 boolean to check if any fired
SpinLocksystem_lock_
OnOffNotifier notifier_
TimerQueue timers_

Friends

class Singleton< TimerSystem >


Member Typedef Documentation

typedef std::priority_queue<Timer*, std::vector<Timer*>, TimerCompare> oasys::TimerSystem::TimerQueue [private]

Definition at line 125 of file Timer.h.


Constructor & Destructor Documentation

oasys::TimerSystem::TimerSystem (  )  [private]

Definition at line 34 of file Timer.cc.

References handlers_, sigfired_, and signals_.

oasys::TimerSystem::~TimerSystem (  )  [private, virtual]

Definition at line 46 of file Timer.cc.

References timers_.


Member Function Documentation

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 
)

Definition at line 96 of file Timer.cc.

References dtnsim::gettimeofday(), and schedule_at().

void oasys::TimerSystem::schedule_immediate ( Timer timer  ) 

Definition at line 112 of file Timer.cc.

References schedule_at().

bool oasys::TimerSystem::cancel ( 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]

Definition at line 193 of file Timer.cc.

References handlers_, log_debug, sigfired_, and signals_.

Referenced by run_expired_timers().


Friends And Related Function Documentation

friend class Singleton< TimerSystem > [friend]

Definition at line 122 of file Timer.h.


Member Data Documentation

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]

Definition at line 135 of file Timer.h.

Referenced by notifier(), post_signal(), and schedule_at().

TimerQueue oasys::TimerSystem::timers_ [private]

Definition at line 136 of file Timer.h.

Referenced by pop_timer(), run_expired_timers(), schedule_at(), and ~TimerSystem().


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