|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This class encapsulates the characteristics source of work for the threading engine. This could be a queue of scheduled tasks, a socket that receives requests, or even a message queue.
Classes that implement this interface can count on "conservation of runnables". Every object created using createRunnable will eventually be returned to the factory either via swapRunnable, in the normal case, or destroyRunnable, in case of error.
This interface is the natural evolution of the ServiceEndpoint class of JRun 2.3. ServiceEndpoint was essentially an interface for a listen socket, but a RunnableFactory has been generalized.
| Field Summary | |
static int |
BUSY
Signifies destroy was called due to being too busy. |
static int |
EXCEPTION
Signifies destroy was called due to an exception. |
static int |
SHUTDOWN
Signifies destroy was called due to a shutdown. |
| Method Summary | |
java.lang.Runnable |
createRunnable()
Returns an Runnable object by doing a protocol-specific accept or receive; the Runnable encapsulates an atomic unit of work. |
void |
destroyRunnable(java.lang.Runnable r,
int reason)
destroy the given runnable. |
void |
invokeRunnable(java.lang.Runnable r)
process this request. |
java.lang.Runnable |
swapRunnable(java.lang.Runnable r)
this is an alternative method for sourcing runnables, letting the runnable factory take care of creation and destruction of the runnable objects. |
| Field Detail |
public static final int BUSY
public static final int SHUTDOWN
public static final int EXCEPTION
| Method Detail |
public java.lang.Runnable createRunnable()
throws java.lang.InterruptedException
java.lang.InterruptedException - if a timeout or interrupt occurs
public java.lang.Runnable swapRunnable(java.lang.Runnable r)
throws java.lang.InterruptedException
returning null from this method is an efficient way to signal no more swapping can be done, without throwing an exception.
ep - a previously used endpoint for recyclingjava.lang.InterruptedException - if an interrupt or timeout occurs.
public void destroyRunnable(java.lang.Runnable r,
int reason)
public void invokeRunnable(java.lang.Runnable r)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||