2020-05-01 00:31:27 +02:00
|
|
|
package it.ernytech.tdlib.utils;
|
|
|
|
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
2020-05-05 17:08:39 +02:00
|
|
|
import java.util.concurrent.Executors;
|
2020-05-01 00:31:27 +02:00
|
|
|
import java.util.concurrent.Future;
|
2020-05-05 17:08:39 +02:00
|
|
|
import java.util.concurrent.ThreadFactory;
|
2020-05-01 00:31:27 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
public interface BoundedExecutorService extends ExecutorService {
|
|
|
|
|
2020-05-13 02:50:51 +02:00
|
|
|
@Deprecated
|
2020-05-01 00:31:27 +02:00
|
|
|
static BoundedExecutorService create(int maxQueueSize,
|
|
|
|
int corePoolSize,
|
|
|
|
int maxPoolSize,
|
|
|
|
long keepAliveTime,
|
|
|
|
TimeUnit unit,
|
|
|
|
@Nullable BiConsumer<Boolean, Integer> queueSizeStatus) {
|
2020-05-05 17:08:39 +02:00
|
|
|
return new BoundedExecutorServiceImpl(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit,
|
|
|
|
Executors.defaultThreadFactory(), queueSizeStatus);
|
|
|
|
}
|
|
|
|
static BoundedExecutorService create(int maxQueueSize,
|
|
|
|
int corePoolSize,
|
|
|
|
int maxPoolSize,
|
|
|
|
long keepAliveTime,
|
|
|
|
TimeUnit unit,
|
|
|
|
ThreadFactory threadFactory,
|
|
|
|
@Nullable BiConsumer<Boolean, Integer> queueSizeStatus) {
|
|
|
|
return new BoundedExecutorServiceImpl(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, threadFactory, queueSizeStatus);
|
2020-05-01 00:31:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
<T> Future<T> submitButBlockIfFull(Callable<T> task) throws InterruptedException;
|
|
|
|
|
|
|
|
void executeButBlockIfFull(Runnable task) throws InterruptedException;
|
|
|
|
}
|