ROOT logo
ROOT » CORE » BASE » TTimer

class TTimer: public TSysEvtHandler


TTimer

Handles synchronous and a-synchronous timer events.
1. synchronous timer is registered into TSystem and is processed
within the standard ROOT event-loop.
2. asynchronous timer is passed to the operating system which sends
an external signal to ROOT and thus interrupts its event-loop.

You can use this class in one of the following ways:
- Sub-class TTimer and override the Notify() method.
- Re-implement the TObject::HandleTimer() method in your class
and pass a pointer to this object to timer, see the SetObject()
method.
- Pass an interpreter command to timer, see SetCommand() method.
- Create a TTimer, connect its Timeout() signal to the
appropriate methods. Then when the time is up it will emit a
Timeout() signal and call connected slots.

Minimum timeout interval is defined in TSystem::ESysConstants as
kItimerResolution (currently 10 ms).

Signal/slots example:
TTimer *timer = new TTimer();
timer->Connect("Timeout()", "myObjectClassName",
myObject, "TimerDone()");
timer->Start(2000, kTRUE);   // 2 seconds single-shot

To emit the Timeout signal repeadetly with minimum timeout:
timer->Start(0, kFALSE);


Function Members (Methods)

public:
TTimer(Long_t milliSec = 0, Bool_t mode = kTRUE)
TTimer(TObject* obj, Long_t milliSec, Bool_t mode = kTRUE)
TTimer(const char* command, Long_t milliSec, Bool_t mode = kTRUE)
virtual~TTimer()
voidTObject::AbstractMethod(const char* method) const
voidTSysEvtHandler::Activate()
virtual voidTSysEvtHandler::Activated()SIGNAL
virtual voidAdd()
virtual voidTSysEvtHandler::Add()
virtual voidTSysEvtHandler::Added()SIGNAL
virtual voidTObject::AppendPad(Option_t* option = "")
static Bool_tTQObject::AreAllSignalsBlocked()
Bool_tTQObject::AreSignalsBlocked() const
static Bool_tTQObject::BlockAllSignals(Bool_t b)
Bool_tTQObject::BlockSignals(Bool_t b)
virtual voidTObject::Browse(TBrowser* b)
virtual voidTQObject::ChangedBy(const char* method)SIGNAL
Bool_tCheckTimer(const TTime& now)
static TClass*Class()
static TClass*TSysEvtHandler::Class()
static TClass*TQObject::Class()
static TClass*TObject::Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
voidTQObject::CollectClassSignalLists(TList& list, TClass* cls)
virtual Int_tTObject::Compare(const TObject* obj) const
Bool_tTQObject::Connect(const char* signal, const char* receiver_class, void* receiver, const char* slot)
static Bool_tTQObject::Connect(TQObject* sender, const char* signal, const char* receiver_class, void* receiver, const char* slot)
static Bool_tTQObject::Connect(const char* sender_class, const char* signal, const char* receiver_class, void* receiver, const char* slot)
virtual voidTQObject::Connected(const char*)
virtual voidTObject::Copy(TObject& object) const
voidTSysEvtHandler::DeActivate()
virtual voidTSysEvtHandler::DeActivated()SIGNAL
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual voidTQObject::Destroyed()SIGNAL
Bool_tTQObject::Disconnect(const char* signal = 0, void* receiver = 0, const char* slot = 0)
static Bool_tTQObject::Disconnect(TQObject* sender, const char* signal = 0, void* receiver = 0, const char* slot = 0)
static Bool_tTQObject::Disconnect(const char* class_name, const char* signal, void* receiver = 0, const char* slot = 0)
virtual voidTQObject::Disconnected(const char*)
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
voidTQObject::Emit(const char* signal)
voidTQObject::Emit(const char* signal, Long_t* paramArr)
voidTQObject::Emit(const char* signal, const char* params)
voidTQObject::Emit(const char* signal, Double_t param)
voidTQObject::Emit(const char* signal, Long_t param)
voidTQObject::Emit(const char* signal, Long64_t param)
voidTQObject::Emit(const char* signal, Bool_t param)
voidTQObject::Emit(const char* signal, Char_t param)
voidTQObject::Emit(const char* signal, UChar_t param)
voidTQObject::Emit(const char* signal, Short_t param)
voidTQObject::Emit(const char* signal, UShort_t param)
voidTQObject::Emit(const char* signal, Int_t param)
voidTQObject::Emit(const char* signal, UInt_t param)
voidTQObject::Emit(const char* signal, ULong_t param)
voidTQObject::Emit(const char* signal, ULong64_t param)
voidTQObject::Emit(const char* signal, Float_t param)
voidTQObject::EmitVA(const char* signal, Int_t nargs)
voidTQObject::EmitVA(const char* signal, Int_t nargs, va_list va)
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
TTimeGetAbsTime() const
const char*GetCommand() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
TList*TQObject::GetListOfClassSignals() const
TList*TQObject::GetListOfConnections() const
TList*TQObject::GetListOfSignals() const
virtual const char*TObject::GetName() const
TObject*GetObject()
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
TTimeGetTime() const
UInt_tGetTimerID()
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual Bool_tTQObject::HasConnection(const char* signal_name) const
virtual ULong_tTObject::Hash() const
Bool_tHasTimedOut() const
virtual voidTQObject::HighPriority(const char* signal_name, const char* slot_name = 0)
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual TClass*TSysEvtHandler::IsA() const
virtual TClass*TObject::IsA() const
Bool_tTSysEvtHandler::IsActive() const
Bool_tIsAsync() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tIsInterruptingSyscalls() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tIsSync() const
Bool_tTObject::IsZombie() const
static voidTQObject::LoadRQ_OBJECT()
virtual voidTQObject::LowPriority(const char* signal_name, const char* slot_name = 0)
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual voidTQObject::Message(const char* msg)SIGNAL
virtual voidTSysEvtHandler::Notified()SIGNAL
virtual Bool_tNotify()
virtual Bool_tTSysEvtHandler::Notify()
virtual Bool_tTObject::Notify()
virtual Int_tTQObject::NumberOfConnections() const
virtual Int_tTQObject::NumberOfSignals() const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject&TObject::operator=(const TObject& rhs)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidRemove()
virtual voidTSysEvtHandler::Remove()
virtual voidTSysEvtHandler::Removed()SIGNAL
voidReset()
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCommand(const char* command)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetInterruptSyscalls(Bool_t set = kTRUE)
voidSetObject(TObject* object)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetTime(Long_t milliSec)
voidSetTimerID(UInt_t id = 0)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidTSysEvtHandler::ShowMembers(TMemberInspector& insp, char* parent)
virtual voidTQObject::ShowMembers(TMemberInspector& insp, char* parent)
virtual voidTObject::ShowMembers(TMemberInspector& insp, char* parent)
static voidSingleShot(Int_t milliSec, const char* receiver_class, void* receiver, const char* method)
virtual voidStart(Long_t milliSec = -1, Bool_t singleShot = kFALSE)
virtual voidStop()
virtual voidStreamer(TBuffer& b)
virtual voidTSysEvtHandler::Streamer(TBuffer& b)
virtual voidTQObject::Streamer(TBuffer& b)
virtual voidTObject::Streamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
voidTSysEvtHandler::StreamerNVirtual(TBuffer& b)
voidTQObject::StreamerNVirtual(TBuffer& b)
voidTObject::StreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTimeout()SIGNAL
virtual voidTurnOff()SIGNAL
virtual voidTurnOn()SIGNAL
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
static Int_tTQObject::CheckConnectArgs(TQObject* sender, TClass* sender_class, const char* signal, TClass* receiver_class, const char* slot)
static Bool_tTQObject::ConnectToClass(TQObject* sender, const char* signal, TClass* receiver_class, void* receiver, const char* slot)
static Bool_tTQObject::ConnectToClass(const char* sender_class, const char* signal, TClass* receiver_class, void* receiver, const char* slot)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual void*TQObject::GetSender()
virtual const char*TQObject::GetSenderClassName() const
voidTObject::MakeZombie()
private:
TTimer(const TTimer&)
TTimer&operator=(const TTimer&)

Data Members

protected:
TTimefAbsTimeabsolute time out time in ms
TStringfCommandinterpreter command to be executed
Bool_tfIntSyscallstrue is a-synchronous timer is to interrupt system calls
TList*TQObject::fListOfConnections! list of connections to this object
TList*TQObject::fListOfSignals! list of signals from this object
TObject*fObjectobject to be notified (if any)
Bool_tTQObject::fSignalsBlocked! flag used for suppression of signals
Bool_tfSynctrue if synchrounous timer
TTimefTimetime out time in ms
UInt_tfTimeIDthe system ID of this timer (for WIN32)
Bool_tfTimeouttrue if timer has timed out
static Bool_tTQObject::fgAllSignalsBlockedflag used for suppression of all signals

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TTimer(Long_t milliSec = 0, Bool_t mode = kTRUE)
 Create timer that times out in ms milliseconds. If milliSec is 0
 then the timeout will be the minimum timeout (see TSystem::ESysConstants,
 i.e. 10 ms). If mode == kTRUE then the timer is synchronous else
 a-synchronous. The default is synchronous. Add a timer to the system
 eventloop by calling TurnOn(). Set command to be executed from Notify()
 or set the object whose HandleTimer() method will be called via Notify(),
 derive from TTimer and override Notify() or connect slots to the
 signals Timeout(), TurnOn() and TurnOff().
TTimer(TObject *obj, Long_t ms, Bool_t mode)
 Create timer that times out in ms milliseconds. If mode == kTRUE then
 the timer is synchronous else a-synchronous. The default is synchronous.
 Add a timer to the system eventloop by calling TurnOn().
 The object's HandleTimer() will be called by Notify().
TTimer(const char *command, Long_t ms, Bool_t mode)
 Create timer that times out in ms milliseconds. If mode == kTRUE then
 the timer is synchronous else a-synchronous. The default is synchronous.
 Add a timer to the system eventloop by calling TurnOn().
 The interpreter will execute command from Notify().
Bool_t CheckTimer(const TTime& now)
 Check if timer timed out.
Bool_t Notify()
 Notify when timer times out. The timer is always reset. To stop
 the timer call TurnOff().
void Reset()
 Reset the timer.
void SetCommand(const char* command)
 Set the interpreter command to be executed at time out. Removes the
 object to be notified (if it was set).
void SetObject(TObject* object)
 Set the object to be notified  at time out. Removes the command to
 be executed (if it was set).
void SetInterruptSyscalls(Bool_t set = kTRUE)
 When the argument is true the a-synchronous timer (SIGALRM) signal
 handler is set so that interrupted syscalls will not be restarted
 by the kernel. This is typically used in case one wants to put a
 timeout on an I/O operation. By default interrupted syscalls will
 be restarted.
void Start(Long_t milliSec = -1, Bool_t singleShot = kFALSE)
 Starts the timer with a milliSec timeout. If milliSec is 0
 then the timeout will be the minimum timeout (see TSystem::ESysConstants,
 i.e. 10 ms), if milliSec is -1 then the time interval as previously
 specified (in ctor or SetTime()) will be used.
 If singleShot is kTRUE, the timer will be activated only once,
 otherwise it will continue until it is stopped.
 See also TurnOn(), Stop(), TurnOff().
void TurnOff()
 Remove timer from system timer list. This requires that a timer
 has been placed in the system timer list (using TurnOn()).
 If a TTimer subclass is placed on another list, override TurnOff() to
 remove the timer from the correct list.
void TurnOn()
 Add the timer to the system timer list. If a TTimer subclass has to be
 placed on another list, override TurnOn() to add the timer to the correct
 list.
void SingleShot(Int_t milliSec, const char* receiver_class, void* receiver, const char* method)
 This static function calls a slot after a given time interval.
 Created internal timer will be deleted after that.
TTimer(const TTimer& )
TTimer& operator=(const TTimer& )
virtual ~TTimer()
{ Remove(); }
const char * GetCommand() const
{ return fCommand.Data(); }
TObject * GetObject()
{ return fObject; }
TTime GetTime() const
{ return fTime; }
UInt_t GetTimerID()
{ return fTimeID;}
TTime GetAbsTime() const
{ return fAbsTime; }
Bool_t HasTimedOut() const
{ return fTimeout; }
Bool_t IsSync() const
{ return fSync; }
Bool_t IsAsync() const
{ return !fSync; }
Bool_t IsInterruptingSyscalls() const
{ return fIntSyscalls; }
void Add()
{ TurnOn(); }
void Remove()
{ TurnOff(); }
void SetTime(Long_t milliSec)
{ fTime = milliSec; }
void SetTimerID(UInt_t id = 0)
{ fTimeID = id; }
void Stop()
{ TurnOff(); }
void Timeout()
{ Emit("Timeout()"); }