26 | * Examples of such resources are database connections, open file handles, socket descriptors 27 | * etc. While similar to {@link AutoCloseable}, this interface should be used when the resource 28 | * release operation may possibly be asynchronous. For example, if an object is thread-safe and 29 | * has many consumers, an implementation may require all current ongoing operations to complete 30 | * before resources are relinquished. 31 | * 32 | *
33 | * May be used with the methods {@link Promises#tryApplyEx(CompletionStage, Function)},
34 | * {@link Promises#tryComposeEx(Promise, Function)} to emulate the behavior of a try
35 | * with resources block.
36 | *
37 | */
38 | @FunctionalInterface
39 | public interface AsyncCloseable {
40 | /**
41 | * Release any resources associated with this object.
42 | *
43 | * @return a {@link CompletionStage} that completes when all resources associated with this object
44 | * have been released, or settled with an exception if the resources cannot be released.
45 | */
46 | CompletionStage Concrete implementation of {@link TaskExecutorService} interface.
30 | * Specialization of {@link ThreadPoolExecutor} that uses {@link Promise} as a result of submit(...)
methods.
23 | *
24 | * @author vsilaev
25 | *
26 | */
27 | public interface TaskExecutorService extends ExecutorService {
28 |
29 | submit(...)
methods.
31 | *
32 | * @author vsilaev
33 | *
34 | */
35 | public class ThreadPoolTaskExecutor extends ThreadPoolExecutor implements TaskExecutorService {
36 |
37 | public ThreadPoolTaskExecutor(int corePoolSize, int maximumPoolSize,
38 | long keepAliveTime, TimeUnit unit,
39 | BlockingQueue