Class CallMappingExecutorService

    • Constructor Detail

      • CallMappingExecutorService

        protected CallMappingExecutorService​(ExecutorService delegate)
        Constructor to create a new wrapper around the specified service delegate.
        Parameters:
        delegate - The delegate executor service that does the heavy lifting of executing all tasks once they are mapped.
    • Method Detail

      • map

        protected abstract <V> Callable<V> map​(Callable<V> callable)
        The call mapping that needs to be implemented: map the given callable object into a desired variant before scheduling.
        Type Parameters:
        V - The type of result being returned by the callable object.
        Parameters:
        callable - The callable to be mapped.
        Returns:
        The mapped callable object.
      • wrap

        protected final <V> Callable<V> wrap​(Callable<V> callable)
        Wrapping a callable object is delegated to the abstract map(Callable) method.
        Overrides:
        wrap in class DelegatingExecutorService
        Type Parameters:
        V - The type of result being returned by the callable object.
        Parameters:
        callable - The callable to be mapped.
        Returns:
        The mapped callable object.
        See Also:
        map(Callable)
      • wrap

        protected Runnable wrap​(Runnable runnable)
        Default implementation to wrap Runnable objects before scheduling: wrap it into a Callable object and return an unwrapped Runnable implementation that simply runs by calling the mapped Callable object.
        Overrides:
        wrap in class DelegatingExecutorService
        Parameters:
        runnable - The runnable object to be wrapped.
        Returns:
        The wrapped runnable (the default implementation re-uses the callable mapping).
        See Also:
        wrap(Callable)