ZFFramework
 
Loading...
Searching...
No Matches
ZFGlobalTimer.h File Reference

timer utility More...

#include "ZFTimer.h"

Go to the source code of this file.

Functions

void ZFGlobalTimerAttach (const ZFListener &timerCallback, ZFLevel observerLevel=(ZFLevelAppNormal))
 global timer util
 
void ZFGlobalTimerAttachOnce (const ZFListener &timerCallback, ZFLevel observerLevel=(ZFLevelAppNormal))
 see ZFGlobalTimerAttach
 
void ZFGlobalTimerDetach (const ZFListener &timerCallback)
 see ZFGlobalTimerAttach
 
void ZFGlobalTimerDetachAll ()
 see ZFGlobalTimerAttach
 
zftimet const & ZFGlobalTimerIntervalDefault ()
 see ZFGlobalTimerAttach
 
void ZFGlobalTimerIntervalDefault (zftimet const &intervalDefault)
 see ZFGlobalTimerAttach
 
zftimet const & ZFGlobalTimerInterval ()
 see ZFGlobalTimerAttach
 
void ZFGlobalTimerInterval (zftimet const &interval)
 see ZFGlobalTimerAttach
 
void ZFGlobalTimerManualStep ()
 manual control global timer step
 
void ZFGlobalTimerManualStepCancel ()
 see ZFGlobalTimerManualStep
 

Detailed Description

timer utility

Function Documentation

◆ ZFGlobalTimerAttach()

void ZFGlobalTimerAttach ( const ZFListener & timerCallback,
ZFLevel observerLevel = (ZFLevelAppNormal) )
extern

global timer util

you can attach any callbacks to same global timer instance, the global timer would be running if more than one timer callback attached, and would be stopped when all of them detached
you can change timer interval by ZFGlobalTimerInterval even when it's running

a typical advanced usage for global timer:

  1. change time based duration to frame based timer by (duration / ZFGlobalTimerIntervalDefault())
  2. step each frame by attaching your update logic to global timer
  3. change ZFGlobalTimerInterval to a greater value, and your logic would be "slowed down"

you may also use ZFGlobalTimerManualStep to manually control the timer steps
note global timer is ensured run in main thread

◆ ZFGlobalTimerManualStep()

void ZFGlobalTimerManualStep ( )
extern

manual control global timer step

once called, all task attached to ZFGlobalTimerAttach would not be notified unless called this method again, you may cancel the manual step and restore to original timer logic by ZFGlobalTimerManualStep