Package jadex.future

Class CallSequentializer<T>

java.lang.Object
jadex.future.CallSequentializer<T>

public class CallSequentializer<T> extends Object
The 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 Details

    • currentcall

      protected IFuture<T> currentcall
      The current call.
    • calls

      protected List<jadex.common.Tuple3<String,Object[],Future<T>>> calls
      The list of waiting calls with future and args.
    • commands

      protected Map<String,jadex.common.IResultCommand<IFuture<T>,Object[]>> commands
      The command to execute a call.
  • Constructor Details

    • CallSequentializer

      public CallSequentializer()
      Create a new sequentializer.
    • CallSequentializer

      public CallSequentializer(jadex.common.IResultCommand<IFuture<T>,Object[]> call)
      Create a new sequentializer.
      Parameters:
      call - The command to execute on an invocation.
  • Method Details

    • addCommand

      public void addCommand(String method, jadex.common.IResultCommand<IFuture<T>,Object[]> call)
      Add a command by (method) name.
      Parameters:
      method - The method name (or just a name).
    • call

      public IFuture<T> call(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.
    • call

      public IFuture<T> call(String method, Object[] args)
    • proceed

      protected void proceed()
      Called when a command returns.