Interface MainThreadExecutable

  • All Known Subinterfaces:
    RpcServer

    public interface MainThreadExecutable
    Interface to execute Runnable and Callable in the main thread of the underlying RPC endpoint.

    This interface is intended to be implemented by the self gateway in a RpcEndpoint implementation which allows to dispatch local procedures to the main thread of the underlying RPC endpoint.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <V> CompletableFuture<V> callAsync​(Callable<V> callable, Duration callTimeout)
      Execute the callable in the main thread of the underlying RPC endpoint and return a future for the callable result.
      void runAsync​(Runnable runnable)
      Execute the runnable in the main thread of the underlying RPC endpoint.
      void scheduleRunAsync​(Runnable runnable, long delay)
      Execute the runnable in the main thread of the underlying RPC endpoint, with a delay of the given number of milliseconds.
    • Method Detail

      • runAsync

        void runAsync​(Runnable runnable)
        Execute the runnable in the main thread of the underlying RPC endpoint.
        Parameters:
        runnable - Runnable to be executed
      • callAsync

        <V> CompletableFuture<V> callAsync​(Callable<V> callable,
                                           Duration callTimeout)
        Execute the callable in the main thread of the underlying RPC endpoint and return a future for the callable result. If the future is not completed within the given timeout, the returned future will throw a TimeoutException.
        Type Parameters:
        V - Return value of the callable
        Parameters:
        callable - Callable to be executed
        callTimeout - Timeout for the future to complete
        Returns:
        Future of the callable result
      • scheduleRunAsync

        void scheduleRunAsync​(Runnable runnable,
                              long delay)
        Execute the runnable in the main thread of the underlying RPC endpoint, with a delay of the given number of milliseconds.
        Parameters:
        runnable - Runnable to be executed
        delay - The delay, in milliseconds, after which the runnable will be executed