|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.zynaptic.reaction.core.ReactorCore
public final class ReactorCore
Implements the main reactor functionality. This class defines the singleton
object which provides all the core functionality of the reactor service. It
exposes the user API via the Reactor interface
and the reactor control API via the ReactorControl interface.
| Method Summary | ||
|---|---|---|
void |
cancelThread(Threadable<?,?> threadable)
Cancels a currently executing threadable task. |
|
void |
cancelTimer(Timeable<?> timeable)
Cancels the timer associated with a given timeable object. |
|
static Reactor |
getReactor()
Accesses the reactor user interface. |
|
static ReactorControl |
getReactorControl()
Accesses the reactor control interface. |
|
Signal<java.lang.Integer> |
getReactorShutdownSignal()
Gets a handle on the reactor shutdown signal. |
|
long |
getUptime()
Gets the elapsed time since the reactor was started. |
|
void |
join()
Waits for the reactor thread to exit. |
|
|
newDeferred()
Creates a new deferred event object. |
|
|
newDeferredConcentrator()
Creates a new deferred callback concentrator object. |
|
|
newDeferredSplitter()
Creates a new deferred callback splitter object. |
|
|
newSignal()
Creates a new signal event object. |
|
|
runThread(Threadable<T,U> threadable,
T data)
Starts executing a threadable task in a new thread. |
|
|
runTimerOneShot(Timeable<T> timeable,
int msDelay,
T data)
Starts a one-shot timer. |
|
|
runTimerRepeating(Timeable<T> timeable,
int msDelay,
int msInterval,
T data)
Starts a repeating timer. |
|
void |
start(MonotonicClockSource clockSource,
ReactorLogTarget logTarget)
Starts the reactor running. |
|
void |
stop()
Requests that the reactor stop running. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final Reactor getReactor()
public static final ReactorControl getReactorControl()
public final void start(MonotonicClockSource clockSource,
ReactorLogTarget logTarget)
throws ThreadableRunningException
ReactorControl
start in interface ReactorControlclockSource - This is a monotonic clock which will be used as the timebase for
the reactor.logTarget - This is the logging service to which all reactor log messages are
redirected.
ThreadableRunningException - This exception is thrown if there is already a reactor thread
running. This indicates a programming error.public final void stop()
ReactorControljoin method.
stop in interface ReactorControl
public final void join()
throws java.lang.InterruptedException
ReactorControlstop method.
join in interface ReactorControljava.lang.InterruptedException - This exception is thrown if the calling thread is interrupted
before the reactor shutdown is complete. An Error is thrown if
the corresponding error condition caused the reactor to shut
down.public final long getUptime()
Reactor
getUptime in interface Reactorpublic final Signal<java.lang.Integer> getReactorShutdownSignal()
Reactor
getReactorShutdownSignal in interface Reactor
public final <T,U> Deferred<U> runThread(Threadable<T,U> threadable,
T data)
throws ReactorNotRunningException,
ThreadableRunningException
Reactor
runThread in interface ReactorT - This type identifier specifies the data type of the parameter
which will be passed as an input to the threadable task.U - This type identifier specifies the data type of the value which
will be returned by the threadable task.threadable - This is the threadable task object which is to be executed in a
separate thread.data - This is the input data object which will be passed to the
run method of the threadable task
object when it is called in the context of the new thread.
ReactorNotRunningException - This exception will be thrown if an attempt is made to schedule
execution of a threadable task object when the reactor is not
running.
ThreadableRunningException - This runtime exception is thrown when an attempt is made to
schedule a threadable object for execution while it is already
being processed by the reactor. This constitutes a programming
error.public final void cancelThread(Threadable<?,?> threadable)
Reactor
cancelThread in interface Reactorthreadable - This is the threadable task object for which threaded execution is
to be cancelled.
public final <T> void runTimerOneShot(Timeable<T> timeable,
int msDelay,
T data)
throws ReactorNotRunningException
Reactor
runTimerOneShot in interface ReactorT - This type identifier specifies the type of the timer data object
which will be passed as the parameter of the timed callback.timeable - This is the timeable object which will have its timed callback
executed after the requested delay.msDelay - This parameter specifies the delay before the timed callback is to
be issued, expressed in milliseconds.data - This is a timer data object which will be passed back as a
parameter to the timed callback.
ReactorNotRunningException - This runtime exception will be thrown if an attempt is made to
schedule a timer when the reactor is not running.
public final <T> void runTimerRepeating(Timeable<T> timeable,
int msDelay,
int msInterval,
T data)
throws ReactorNotRunningException
Reactor
runTimerRepeating in interface ReactorT - This type identifier specifies the type of the timer data object
which will be passed as the parameter of the timed callback.timeable - This is the timeable object which will have its timed callback
executed at the requested interval.msDelay - This is the delay before the first timed callback is issued,
specified in milliseconds.msInterval - This is the interval at which timed callbacks will be issued,
specified in milliseconds. If set to 0 or a negative value, the
timer is treated as a one-shot timer.data - This is a timer data object which will be passed back as a
parameter to the timed callbacks.
ReactorNotRunningException - This exception will be thrown if an attempt is made to schedule a
timer when the reactor is not running.public final void cancelTimer(Timeable<?> timeable)
Reactor
cancelTimer in interface Reactortimeable - This is the timeable object for which the associated running timer
should be cancelled.public final <T> Deferred<T> newDeferred()
ReactorDeferred interface.
newDeferred in interface ReactorT - This type identifier specifies the data type of the object which
should be passed as the callback
parameter for the new deferred event object.
public final <T> DeferredSplitter<T> newDeferredSplitter()
ReactorDeferredSplitter interface.
newDeferredSplitter in interface ReactorT - This type identifier specifies the type of the callback data
object which will be passed through the deferred splitter.
public final <T> DeferredConcentrator<T> newDeferredConcentrator()
ReactorDeferredConcentrator interface.
newDeferredConcentrator in interface ReactorT - This type identifier specifies the type of the callback data
object which will be passed through the deferred concentrator.
public final <T> Signal<T> newSignal()
ReactorSignal interface.
newSignal in interface ReactorT - This type identifier specifies the type of the data object which
will be passed as the parameter to the
onSignal signalable
callbacks.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||