Class CloseableExecutor
- java.lang.Object
-
- com.opengamma.strata.collect.concurrent.CloseableExecutor
-
- All Implemented Interfaces:
AutoCloseable
public class CloseableExecutor extends Object implements AutoCloseable
AutoCloseable wrapper around an executor.This shuts down the wrapped executor when it is closed, and can wait for tasks to exit.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static CloseableExecutor
of(ExecutorService executor)
Returns a closeable executor that wraps a passed in executor.static CloseableExecutor
of(ExecutorService executor, Duration duration)
Returns a closeable executor that wraps a passed in executor.
-
-
-
Method Detail
-
of
public static CloseableExecutor of(ExecutorService executor)
Returns a closeable executor that wraps a passed in executor.The passed in executor is shut down when the returned CloseableExecutor is closed.
- Parameters:
executor
- the executor to wrap- Returns:
- a CloseableExecutor
-
of
public static CloseableExecutor of(ExecutorService executor, Duration duration)
Returns a closeable executor that wraps a passed in executor.The passed in executor is shut down when the returned CloseableExecutor is closed, and waits for the given duration for tasks to finish.
- Parameters:
executor
- the executor to wrapduration
- the duration to wait for tasks to exit- Returns:
- a CloseableExecutor
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-