A low-precision timer driven by the update loop.
The timer is configured with an interval in milliseconds. Each frame after the timer has been started, the elapsed time will be compared against the interval - and if it is larger than or equal to the interval, the TimedOut signal will be emitted.
Because the signal can only be emitted during CYIApp::Update, this timer cannot be more precise than the time between updates. The TimedOut signal can be delayed by an extra frame if the signal connection happens across threads.
The timer has two modes of operation - single shot and repeated. Single shot mode is the default.
#include <utility/YiTimer.h>

Public Types | |
| enum | STATE { OFF = 0, RUNNING, SUSPENDED } |
Public Member Functions | |
| CYITimer () | |
| CYITimer (int32_t nTimerID) | |
| virtual | ~CYITimer () |
| uint64_t | GetInterval () const |
| STATE | GetState () const |
| bool | IsSingleShot () const |
| void | SetInterval (uint64_t uIntervalMs) |
| void | SetSingleShot (bool bSingleShot) |
| void | Start (uint64_t uIntervalMs) |
| void | Start () |
| void | Stop () |
| void | Suspend () |
| void | Resume () |
| void | SetTimerID (int32_t nTimerID) |
| int32_t | GetTimerID () const |
Public Member Functions inherited from CYISignalHandler | |
| CYISignalHandler () | |
| CYISignalHandler (const CYISignalHandler &rSignalHandler) | |
| virtual | ~CYISignalHandler () |
| CYISignalHandler & | operator= (const CYISignalHandler &rSignalHandler) |
| void | MoveToThread (CYIThread *pThread) |
| This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More... | |
| CYIThreadHandle | GetThreadAffinity () const |
| void | SetThreadAffinity (const CYIThreadHandle &rThreadAffinity) |
| virtual bool | IsConnected () const |
| virtual bool | IsConnected (const CYISignalBase &rSignal) const |
| void | Disconnect (CYISignalBase &rSignal) |
| void | DisconnectFromAllSignals () |
Public Member Functions inherited from CYIThread::Listener | |
| Listener () | |
| virtual | ~Listener () |
| virtual void | OnThreadStarted (CYIThread *) |
| virtual void | OnThreadTerminated (CYIThread *) |
| virtual void | OnThreadFinished (CYIThread *) |
Public Member Functions inherited from CYIScriptableObject | |
| CYIScriptableObject () | |
| CYIScriptableObject (const CYIScriptableObject &other) | |
| CYIScriptableObject & | operator= (const CYIScriptableObject &other) |
| virtual | ~CYIScriptableObject () |
| CYIBindingImplementation * | GetBindingImplementation () const |
| void | SetBindingImplementation (CYIBindingImplementation *pBindingImplementation) |
| virtual const CYIRuntimeTypeInfo * | GetRuntimeTypeInfoForScriptObject () const |
Public Attributes | |
| CYISignal< int32_t > | TimedOut |
| enum CYITimer::STATE |
| CYITimer::CYITimer | ( | ) |
Creates a new timer instance with ID defaulted to 0.
The initial state is OFF.
| CYITimer::CYITimer | ( | int32_t | nTimerID | ) |
Creates a new timer instance which can be identified by its ID, nTimerID.
The initial state is OFF.
|
virtual |
| uint64_t CYITimer::GetInterval | ( | ) | const |
Returns the currently configured timeout interval for this timer. The returned value is specified in milliseconds.
| int32_t CYITimer::GetTimerID | ( | ) | const |
| bool CYITimer::IsSingleShot | ( | ) | const |
Returns true if the timer is configured to be single shot. The default value is true.
| void CYITimer::Resume | ( | ) |
| void CYITimer::SetInterval | ( | uint64_t | uIntervalMs | ) |
Sets uIntervalMs as the interval for the next TimedOut signal call, in milliseconds.
| void CYITimer::SetSingleShot | ( | bool | bSingleShot | ) |
| void CYITimer::SetTimerID | ( | int32_t | nTimerID | ) |
Specify nTimerID as the ID to be passed back when the timer expires. The default value is 0.
| void CYITimer::Start | ( | uint64_t | uIntervalMs | ) |
Sets the interval to nIntervalMs and starts or re-starts the timer.
As a result the timer will be in the RUNNING state and the timer starts counting from 0.
If the timer was already running when Start() is called, the TimedOut signal will not be fired until the end of the new interval.
| void CYITimer::Start | ( | ) |
Starts or re-starts the timer with the currently configured interval value.
| void CYITimer::Stop | ( | ) |
| void CYITimer::Suspend | ( | ) |
| CYISignal<int32_t> CYITimer::TimedOut |
Emitted when the timer is in the RUNNING state and the timer interval ends.
The integer parameter indicates the ID set on this timer.