|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.asyncobjects.util.Serialized<T>
T
- Value typepublic abstract class Serialized<T>
This class respresents action serialized over request queue. The class is basically an asynchronous version of Java's "synchronized" statement. The request queue ensures that instaces of this class are executed in FIFO order. It is used like the following:
class Test { RequestQueue queue = new RequestQueue(); public Object method1() { return new Serialized(queue) { protected Object run() { // do actions of method 1 return promiseOrValue; } }.start(); } public Object method2() { return new Serialized(queue) { protected Object run() { // do actions of method 2 return promiseOrValue; } }.start(); } }
In the example above, only one method invocation could be active at the same time even if actions will spawn several turns.
Constructor Summary | |
---|---|
Serialized(RequestQueue queue)
A constructor from queue |
Method Summary | |
---|---|
Promise<T> |
promise()
Return a promise for action execution. |
protected abstract Promise<? extends T> |
run()
Action that should be queue on request queue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Serialized(RequestQueue queue)
queue
- a request queueMethod Detail |
---|
protected abstract Promise<? extends T> run() throws Throwable
Throwable
- if there is a problem during running actionpublic final Promise<T> promise()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |