com.zynaptic.reaction
Interface Threadable<T,U>
- Type Parameters:
T - This type parameter specifies the type of data object which may be
passed into the threadable task.U - This type parameter specifies the type of data object which will be
passed back by the threadable task on completion.
public interface Threadable<T,U>
Defines the interface to a threadable task object. Threadable task objects
can be submitted to the reactor in order to run in a separate thread. This is
useful for executing code which contains blocking calls within the Reaction
framework. On submitting a threadable task object to the reactor using the
runThread method on the
Reactor interface, an object implementing the Deferred
interface is returned which will be used to forward the results generated by
the run method on completion.
|
Method Summary |
U |
run(T data)
Runs a threadable task in the context of a new thread. |
run
U run(T data)
throws java.lang.Exception
- Runs a threadable task in the context of a new thread. On submitting an
object implementing this interface for threaded execution, this method will
be called by the reactor in the context of a new thread. On normal
completion it will return a data object which will be passed as the
callback parameter to the deferred callback chain. Alternatively, if an
exception is thrown this will be passed as the errback parameter to the
error callback chain.
- Parameters:
data - This is the input data object which is provided when submitting
the threadable task object to the reactor.
- Returns:
- Returns an output data object which will be passed to the deferred
callback chain as the
onCallback
parameter.
- Throws:
java.lang.Exception - On an exception, the exception object is passed to the deferred
error callback chain as the
onErrback
parameter.