Package jadex.commons.future
Class CallSequentializer<T>
- java.lang.Object
-
- jadex.commons.future.CallSequentializer<T>
-
public class CallSequentializer<T> extends java.lang.ObjectThe call sequentializer realizes a 'critical region' for async calls, i.e. it sequentializes access to a method. - It uses a command to call the method - It guarantees first come first served method invocation.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Tuple3<java.lang.String,java.lang.Object[],Future<T>>>callsThe list of waiting calls with future and args.protected java.util.Map<java.lang.String,IResultCommand<IFuture<T>,java.lang.Object[]>>commandsThe command to execute a call.protected IFuture<T>currentcallThe current call.
-
Constructor Summary
Constructors Constructor Description CallSequentializer()Create a new sequentializer.CallSequentializer(IResultCommand<IFuture<T>,java.lang.Object[]> call)Create a new sequentializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(java.lang.String method, IResultCommand<IFuture<T>,java.lang.Object[]> call)Add a command by (method) name.IFuture<T>call(java.lang.Object[] args)Handles a call.IFuture<T>call(java.lang.String method, java.lang.Object[] args)protected voidproceed()Called when a command returns.
-
-
-
Constructor Detail
-
CallSequentializer
public CallSequentializer()
Create a new sequentializer.
-
CallSequentializer
public CallSequentializer(IResultCommand<IFuture<T>,java.lang.Object[]> call)
Create a new sequentializer.- Parameters:
call- The command to execute on an invocation.
-
-
Method Detail
-
addCommand
public void addCommand(java.lang.String method, IResultCommand<IFuture<T>,java.lang.Object[]> call)Add a command by (method) name.- Parameters:
method- The method name (or just a name).
-
call
public IFuture<T> call(java.lang.Object[] args)
Handles a call. If no other call is in it will execute the command. If at least one call is in it will be added to the calls list. When a call finishes the next is fetched from the list until empty.- Parameters:
args- The call args.- Returns:
- The call result future.
-
proceed
protected void proceed()
Called when a command returns.
-
-