RTP Audio System  2.0.0
TimedThread Class Reference

Timed Thread. More...

#include <timedthread.h>

Inheritance diagram for TimedThread:
MultiTimerThread< Timers > Thread Synchronizable AbstractMediaServer AdvancedAudioDecoder BandwidthManager RoundTripTimePinger RTCPAbstractServer RTCPSender RTPSender TrafficShaperSingleton

List of all members.

Public Member Functions

 TimedThread (const card64 usec, const char *name="TimedThread", const cardinal flags=TF_CancelDeferred)
 ~TimedThread ()
card64 getInterval ()
void setInterval (const card64 usec)
void setNextAction (const card64 usec=0, const card64 callLimit=1)
void setNextActionAbs (const card64 timeStamp=0, const card64 callLimit=1)
cardinal getTimerCorrection ()
void setTimerCorrection (const cardinal maxCorrection=0)
void leaveCorrectionLoop ()
void setFastStart (const bool on)
bool getFastStart () const

Protected Member Functions

virtual void timerEvent ()=0

Private Member Functions

void timerEvent (const cardinal timer)

Detailed Description

Timed Thread.

This abstract class realizes a timed thread based on MultiTimerThread. The user of this class has to implement timerEvent(). Inaccurate system timers are corrected by calling user's timerEvent() implementation multiple times if necessary. This feature can be modified by setTimerCorrection (Default is on at a maximum of 10 calls).

Author:
Thomas Dreibholz
Version:
1.0
See also:
Thread

Constructor & Destructor Documentation

TimedThread::TimedThread ( const card64  usec,
const char *  name = "TimedThread",
const cardinal  flags = TF_CancelDeferred 
)

Constructor. A new timed thread with a given interval will be created but *not* started! To start the new thread, call start(). The interval gives the time for the interval in microseconds, the virtual function timerEvent() is called. The default timer correction is set to 10. See setTimerCorrection() for more information on timer correction. The first call of timerEvent() will be made immediately, if the fast start option is set (default). Otherwise it will be made after the given interval.

Parameters:
usecInterval in microseconds.
nameThread name.
flagsThread flags.
See also:
Thread::start
timerEvent
Thread::Thread
setTimerCorrection
setFastStart

Destructor.


Member Function Documentation

bool TimedThread::getFastStart ( ) const [inline]

Get fast start option: If false, the first call of timerEvent() will be made *after* the given interval; otherwise it will be made immediately.

Returns:
true, if option is set; false otherwise.

Get timed thread's interval.

Returns:
Interval in microseconds.

Get maxCorrection value for inaccurate system timer.

Returns:
true, if activated; false if not.
See also:
setTimerCorrection

Leave timer correction loop: If the thread is in a timer correction loop, the loop will be finished after the current timerEvent() call returns.

void TimedThread::setFastStart ( const bool  on) [inline]

Set fast start option: If false, the first call of timerEvent() will be made *after* the given interval; otherwise it will be made immediately. The default is true.

Parameters:
ontrue, to set option; false otherwise.
void TimedThread::setInterval ( const card64  usec) [inline]

Set timed thread's interval.

Parameters:
usecInterval in microseconds.
void TimedThread::setNextAction ( const card64  usec = 0,
const card64  callLimit = 1 
) [inline]

Like setInterval(), but disabling FastStart first. This method can be used e.g. for a single shot timer.

Parameters:
usecTime to next invokation (0 = immediately).
callLimitCall count limit (0 for infinite, default: 1).
See also:
setInterval
void TimedThread::setNextActionAbs ( const card64  timeStamp = 0,
const card64  callLimit = 1 
) [inline]

Like setNextAction(), but the time stamp of the next invokation is given as absolute time (microseconds since January 01, 1970).

Parameters:
usecTime to next invokation (0 = immediately).
callLimitCall count limit (0 for infinite, default: 1).
See also:
setInterval
setNextAction
void TimedThread::setTimerCorrection ( const cardinal  maxCorrection = 0) [inline]

Set correction of inaccurate system timer to given value. This on will cause the timerEvent() function to be called a maximum of maxCorrection times, if the total number of calls is lower than the calculated number of times the function should have been called. If the number of correction calls is higher than maxCorrection, *no* correction will be done! Default is 0, which turns correction off.

Parameters:
oftrue to activate correction; false to deactivate.
virtual void TimedThread::timerEvent ( ) [protected, pure virtual]

The virtual timerEvent() method, which contains the timed thread's implementation. It has to be implemented by classes, which inherit TimedThread. This method is called regularly with the given interval.

Implemented in AbstractMediaServer, BandwidthManager, RTCPAbstractServer, RoundTripTimePinger, RTPSender, AdvancedAudioDecoder, RTCPSender, and TrafficShaperSingleton.

void TimedThread::timerEvent ( const cardinal  timer) [private, virtual]

The virtual timerEvent() method, which contains the multitimer thread's implementation. It has to be implemented by classes, which inherit MultiTimerThread. This method is called regularly with the given interval.

Implements MultiTimerThread< Timers >.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines