//*CMZ : 2.00/12 05/10/98 19.18.59 by Fons Rademakers
//*CMZ : 2.00/11 25/08/98 01.45.05 by Fons Rademakers
//*CMZ : 1.00/06 23/03/97 11.01.59 by Rene Brun
//*-- Author : Fons Rademakers 28/11/96
//*KEEP,CopyRight,T=C.
/*************************************************************************
* Copyright(c) 1995-1998, The ROOT System, All rights reserved. *
* Authors: Rene Brun, Nenad Buncic, Valery Fine, Fons Rademakers. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation for non-commercial purposes is hereby granted without *
* fee, provided that the above copyright notice appears in all copies *
* and that both the copyright notice and this permission notice appear *
* in the supporting documentation. The authors make no claims about the *
* suitability of this software for any purpose. *
* It is provided "as is" without express or implied warranty. *
*************************************************************************/
//*KEND.
//////////////////////////////////////////////////////////////////////////
// //
// TTimer //
// //
// Handles synchronous and a-synchronous timer events. To make use of //
// this class one has to sub-class TTimer and implement Notify() and //
// Remove() (if timer has not been added to the gSystem timer list). //
// Without sub-classing one can use the HasTimedOut() method. //
// Use Reset() to reset the timer after expiration. To disable a timer //
// remove it using Remove() or destroy it. //
// //
//////////////////////////////////////////////////////////////////////////
//*KEEP,TTimer,T=C++.
#include "TTimer.h"
//*KEEP,TSystem.
#include "TSystem.h"
//*KEND.
ClassImp(TTimer)
//______________________________________________________________________________
TTimer::TTimer(Long_t ms, Bool_t mode) : fTime(ms)
{
// 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 doing: gSystem->AddTimer().
fSync = mode;
Reset();
}
//______________________________________________________________________________
Bool_t TTimer::CheckTimer(const TTime &now)
{
// Check if timer timed out.
if (fAbsTime <= now) {
fTimeout = kTRUE;
Notify();
return kTRUE;
}
return kFALSE;
}
//______________________________________________________________________________
Bool_t TTimer::Notify()
{
// Notify when timer times out
return kFALSE;
}
//______________________________________________________________________________
void TTimer::Reset()
{
// Reset the timer.
fTimeout = kFALSE;
fAbsTime = fTime;
if (gSystem) {
fAbsTime += gSystem->Now();
if (!fSync) gSystem->ResetTimer(this);
}
}
//______________________________________________________________________________
void TTimer::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.
if (gSystem)
gSystem->RemoveTimer(this);
}
//______________________________________________________________________________
void TTimer::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.
if (gSystem)
gSystem->AddTimer(this);
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.