Reaction Home

com.zynaptic.reaction.core
Interface ReactorControl

All Known Implementing Classes:
ReactorCore

public interface ReactorControl

Defines the API for controlling the reactor service. The reactor object is always a singleton and this interface can only be accessed via its getReactorControl static method.


Method Summary
 void join()
          Waits for the reactor thread to exit.
 void start(MonotonicClockSource clockSource, ReactorLogTarget logTarget)
          Starts the reactor running.
 void stop()
          Requests that the reactor stop running.
 

Method Detail

start

void start(MonotonicClockSource clockSource,
           ReactorLogTarget logTarget)
           throws ThreadableRunningException
Starts the reactor running. This method is called in order to start the main reactor thread, using the supplied monotonic clock as its timebase. It is called from a separate host thread and will return once the reactor thread has started running.

Parameters:
clockSource - 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.
Throws:
ThreadableRunningException - This exception is thrown if there is already a reactor thread running. This indicates a programming error.

stop

void stop()
Requests that the reactor stop running. This method is called in order to stop the reactor from running. It may be called from any thread context, including the main reactor thread. This method returns immediately and if the calling thread wishes to wait for the reactor to shut down it should follow it with a call to the join method.


join

void join()
          throws java.lang.InterruptedException
Waits for the reactor thread to exit. This method may be called from any thread except the main reactor thread in order to wait for the reactor thread to exit. It is typically called immediately after the host thread has called the stop method.

Throws:
java.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.

Reaction Home