FMLiveSwitchManagedTimer Class Reference

A managed timer that will tick on intervals. More...

Instance Methods

(void) - changeIntervalWithNewInterval:
 Changes the interval of the timer. More...
 
(instancetype) - initWithInterval:callback:
 Creates a new instance of the managed timer. More...
 
(int) - interval
 Gets the interval that the timer will tick on. More...
 
(bool) - inTick
 Gets whether the callback is currently being called. More...
 
(bool) - running
 Gets whether the timer is running. More...
 
(bool) - start
 Starts the timer. More...
 
(bool) - stop
 Stops the timer. More...
 
(FMLiveSwitchFuture< id > *) - stopAsync
 Stops the timer. More...
 
(bool) - stopWithWaitForStop:
 Stops the timer. More...
 

Class Methods

(FMLiveSwitchManagedTimer *) + managedTimerWithInterval:callback:
 Creates a new instance of the managed timer. More...
 
(int) + perSecondIntervalWithTimesPerSecond:
 Calculates a interval based on how many times you want the timer to tick per second. More...
 

Detailed Description

A managed timer that will tick on intervals.

Might catchup if callback takes too long.

Method Documentation

◆ changeIntervalWithNewInterval:

- (void) changeIntervalWithNewInterval: (int)  newInterval

Changes the interval of the timer.

Parameters
newInterval

◆ initWithInterval:callback:

- (instancetype) initWithInterval: (int)  interval
callback: (FMLiveSwitchAction0 *)  callback 

Creates a new instance of the managed timer.

Parameters
intervalThe millisecond interval to tick on.
callbackThe callback to use when a tick occurs.

◆ interval

- (int) interval

Gets the interval that the timer will tick on.

◆ inTick

- (bool) inTick

Gets whether the callback is currently being called.

◆ managedTimerWithInterval:callback:

+ (FMLiveSwitchManagedTimer*) managedTimerWithInterval: (int)  interval
callback: (FMLiveSwitchAction0 *)  callback 

Creates a new instance of the managed timer.

Parameters
intervalThe millisecond interval to tick on.
callbackThe callback to use when a tick occurs.

◆ perSecondIntervalWithTimesPerSecond:

+ (int) perSecondIntervalWithTimesPerSecond: (double)  timesPerSecond

Calculates a interval based on how many times you want the timer to tick per second.

Parameters
timesPerSecondThe amount of times to tick per second.

◆ running

- (bool) running

Gets whether the timer is running.

◆ start

- (bool) start

Starts the timer.

Returns
false if the timer was already started; otherwise, true.

◆ stop

- (bool) stop

Stops the timer.

Returns
false if the timer was already stopped; otherwise, true.

◆ stopAsync

- (FMLiveSwitchFuture<id>*) stopAsync

Stops the timer.

Returns
false if the timer was already stopped; otherwise, true.

◆ stopWithWaitForStop:

- (bool) stopWithWaitForStop: (bool)  waitForStop

Stops the timer.

Parameters
waitForStopTrue if method should block until timer is stopped.
Returns
false if the timer was already stopped; otherwise, true.