Package jadex.commons.future
Class CallMultiplexer
- java.lang.Object
-
- jadex.commons.future.CallMultiplexer
-
public class CallMultiplexer extends java.lang.Object
The CallMultiplexer unifies multiple executions of "similar" commands to a single execution. Multiple threads can attempt to call the command. When a "similar" call is already in progress, the thread will wait for the results of the call in progress instead of executing the command itself. Calls are considered "similar" depending on the chosen doCall() method. Similarity can depend simply on the command class itself, a set of key command parameters or both.
-
-
Constructor Summary
Constructors Constructor Description CallMultiplexer()
Instantiates a call multiplexer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<?>
doCall(IResultCommand<java.lang.Object,java.lang.Object> call)
Calls the command.IFuture<?>
doCall(java.lang.Object keyargs, IResultCommand<java.lang.Object,java.lang.Object> call)
Calls the command.IFuture<?>
doCall(java.lang.Object keyargs, IResultCommand<java.lang.Object,java.lang.Object> call, boolean commandaskey)
Calls the command.
-
-
-
Field Detail
-
futuremap
protected java.util.Map<java.lang.Object,IFuture<?>> futuremap
Map of futures of calls that are in progress.
-
-
Method Detail
-
doCall
public IFuture<?> doCall(IResultCommand<java.lang.Object,java.lang.Object> call)
Calls the command. If a "similar" call is in progress, wait for that call's results instead. All commands of the same class are considered "similar".- Parameters:
call
- The command.- Returns:
- The results, either from executing the call or "hitchhiking" on a "similar" call.
-
doCall
public IFuture<?> doCall(java.lang.Object keyargs, IResultCommand<java.lang.Object,java.lang.Object> call)
Calls the command. If a "similar" call is in progress, wait for that call's results instead. All commands of the same class with the same key arguments are considered "similar".- Parameters:
keyargs
- Key argument to differentiate whether calls are similar in addition to the command class, may be an array.call
- The command.- Returns:
- The results, either from executing the call or "hitchhiking" on a "similar" call.
-
doCall
public IFuture<?> doCall(java.lang.Object keyargs, IResultCommand<java.lang.Object,java.lang.Object> call, boolean commandaskey)
Calls the command. If a "similar" call is in progress, wait for that call's results instead. All commands with the same key arguments and/or command class are considered "similar".- Parameters:
keyargs
- Key argument to differentiate whether calls are similar in addition to the command class, may be an array.call
- The command.commandaskey
- Flag whether to consider the command class as part of the key differentiating calls.- Returns:
- The results, either from executing the call or "hitchhiking" on a "similar" call.
-
-