Class CallSequentializer<T>


  • public class CallSequentializer<T>
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<Tuple3<java.lang.String,​java.lang.Object[],​Future<T>>> calls
      The list of waiting calls with future and args.
      protected java.util.Map<java.lang.String,​IResultCommand<IFuture<T>,​java.lang.Object[]>> commands
      The command to execute a call.
      protected IFuture<T> currentcall
      The current call.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCommand​(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 void proceed()
      Called when a command returns.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • currentcall

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

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

        protected java.util.Map<java.lang.String,​IResultCommand<IFuture<T>,​java.lang.Object[]>> commands
        The command to execute a call.
    • 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.
      • call

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

        protected void proceed()
        Called when a command returns.