fm.liveswitch.ManagedTimer Class Reference

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

Public Member Functions

void changeInterval (int newInterval)
 Changes the interval of the timer. More...
 
String getId ()
 Gets the Id of the timer. More...
 
int getInterval ()
 Gets the interval that the timer will tick on. More...
 
boolean getInTick ()
 Gets whether the callback is currently being called. More...
 
boolean getRunning ()
 Gets whether the timer is running. More...
 
 ManagedTimer (int interval, fm.liveswitch.IAction0 callback)
 Creates a new instance of the managed timer. More...
 
boolean start ()
 Starts the timer. More...
 
boolean stop ()
 Stops the timer. More...
 
boolean stop (boolean waitForStop)
 Stops the timer. More...
 
fm.liveswitch.Future< Object > stopAsync ()
 Stops the timer. More...
 

Static Public Member Functions

static int perSecondInterval (double timesPerSecond)
 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.

Constructor & Destructor Documentation

◆ ManagedTimer()

fm.liveswitch.ManagedTimer.ManagedTimer ( int  interval,
fm.liveswitch.IAction0  callback 
)

Creates a new instance of the managed timer.

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

Member Function Documentation

◆ changeInterval()

void fm.liveswitch.ManagedTimer.changeInterval ( int  newInterval)

Changes the interval of the timer.

Parameters
newInterval

◆ getId()

String fm.liveswitch.ManagedTimer.getId ( )

Gets the Id of the timer.

◆ getInterval()

int fm.liveswitch.ManagedTimer.getInterval ( )

Gets the interval that the timer will tick on.

◆ getInTick()

boolean fm.liveswitch.ManagedTimer.getInTick ( )

Gets whether the callback is currently being called.

◆ getRunning()

boolean fm.liveswitch.ManagedTimer.getRunning ( )

Gets whether the timer is running.

◆ perSecondInterval()

static int fm.liveswitch.ManagedTimer.perSecondInterval ( double  timesPerSecond)
static

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.

◆ start()

boolean fm.liveswitch.ManagedTimer.start ( )

Starts the timer.

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

◆ stop() [1/2]

boolean fm.liveswitch.ManagedTimer.stop ( )

Stops the timer.

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

◆ stop() [2/2]

boolean fm.liveswitch.ManagedTimer.stop ( boolean  waitForStop)

Stops the timer.

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

◆ stopAsync()

fm.liveswitch.Future<Object> fm.liveswitch.ManagedTimer.stopAsync ( )

Stops the timer.

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