fm.liveswitch.ManagedThread Class Reference

A managed thread. More...

Public Member Functions

 ManagedThread (final IAction1< ManagedThread > loop)
 Initializes a new instance of the ManagedThread class. More...
 
void start ()
 Starts the thread. More...
 
void loopBegin ()
 Should be invoked when the loop begins before other code. More...
 
void loopEnd ()
 Should be invoked when the loop ends after other code. More...
 

Static Public Member Functions

static long getCurrentThreadId ()
 Gets the id for the current thread. More...
 
static void sleep (int millisecondsTimeout)
 Sleeps the current thread for a specified period of time. More...
 
static void dispatch (final IAction0 action)
 Dispatches an action to a background thread. More...
 
static Future< Object > delay (long millis) throws Exception
 Returns a promise that gets resolved after a specified amount of time. More...
 

Detailed Description

A managed thread.

Constructor & Destructor Documentation

◆ ManagedThread()

fm.liveswitch.ManagedThread.ManagedThread ( final IAction1< ManagedThread loop)

Initializes a new instance of the ManagedThread class.

Parameters
loopThe loop to run on the thread.

Member Function Documentation

◆ delay()

static Future<Object> fm.liveswitch.ManagedThread.delay ( long  millis) throws Exception
static

Returns a promise that gets resolved after a specified amount of time.

Parameters
millisThe length of time to delay in milliseconds. cannot be greater than 2147483646 ms.
Returns
Promise that gets resolved when the delay is complete.

◆ dispatch()

static void fm.liveswitch.ManagedThread.dispatch ( final IAction0  action)
static

Dispatches an action to a background thread.

Parameters
actionThe action.

◆ getCurrentThreadId()

static long fm.liveswitch.ManagedThread.getCurrentThreadId ( )
static

Gets the id for the current thread.

◆ loopBegin()

void fm.liveswitch.ManagedThread.loopBegin ( )

Should be invoked when the loop begins before other code.

◆ loopEnd()

void fm.liveswitch.ManagedThread.loopEnd ( )

Should be invoked when the loop ends after other code.

◆ sleep()

static void fm.liveswitch.ManagedThread.sleep ( int  millisecondsTimeout)
static

Sleeps the current thread for a specified period of time.

Parameters
millisecondsTimeoutThe length of time to sleep in milliseconds.

◆ start()

void fm.liveswitch.ManagedThread.start ( )

Starts the thread.