public class ApexExecutorsHelper extends Object
ExecutorService, easy splitting of tasks| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
allowTryMax |
static int |
CORE_KEEP_ALIVE_IN_SECONDS
The number of seconds a Thread is kept alive before being closed if not used
|
static RejectedExecutionHandler |
DEFAULT_ABORT_POLICY |
static int |
DEFAULT_ACTIVE_TASKS
Consider at most 2 active task per Nb of cores to have not too many tasks, but workaround IO latencies
|
static int |
DEFAULT_LOG_ON_SLOW_QUEUE_MS |
static int |
DEFAULT_MINIMUM_QUEUE_SIZE |
static int |
DEFAULT_NB_CORES |
static int |
DEFAULT_PARTITION_TASK_SIZE |
static int |
DEFAULT_QUEUE_CAPACITY |
static RejectedExecutionHandler |
DEFAULT_REJECTION_POLICY |
static int |
DEFAULT_SPLIT_TASK_SIZE
Deprecated.
|
protected static org.slf4j.Logger |
LOGGER |
static RejectedExecutionHandler |
TIMEOUT_POLICY_1_HOUR |
| Modifier | Constructor and Description |
|---|---|
protected |
ApexExecutorsHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <T> long |
consumeByTimeBlock(Consumer<Long> c,
Stream<T> conditionsToUpdate,
int niceTransactionSeconds,
Object object) |
static void |
executeAllRunnable(Collection<? extends Runnable> tasks,
com.google.common.util.concurrent.ListeningExecutorService executorService)
Same as ExecutorService#invokeAll(Collection, long, TimeUnit) but for
Runnable. |
static int |
getDefaultNbThreads() |
static <T> List<? extends com.google.common.util.concurrent.ListenableFuture<T>> |
invokeAll(Collection<? extends Callable<? extends T>> tasks,
com.google.common.util.concurrent.ListeningExecutorService executorService,
long timeout,
TimeUnit unit)
Softer generic signature
|
static <T> List<? extends com.google.common.util.concurrent.ListenableFuture<T>> |
invokeAll(Collection<? extends Supplier<? extends T>> tasks,
com.google.common.util.concurrent.ListeningExecutorService executorService)
Softer generic signature
|
static List<? extends com.google.common.util.concurrent.ListenableFuture<?>> |
invokeAllRunnable(Collection<? extends Runnable> tasks,
com.google.common.util.concurrent.ListeningExecutorService executorService,
long timeout,
TimeUnit unit)
Same as ExecutorService#invokeAll(Collection, long, TimeUnit) but for
Runnable |
static ThreadFactory |
makeDaemonThreadFactory(String threadNamePrefix) |
static RejectedExecutionHandler |
makeRejectedExecutionHandler(int timeout,
TimeUnit unit)
Deprecated.
|
static ForkJoinPool |
newForkJoinPool(String threadPrefix) |
static ForkJoinPool |
newForkJoinPool(String threadPrefix,
int parallelism) |
static com.google.common.util.concurrent.ListeningExecutorService |
newShrinkableCachedThreadPool(String threadNamePrefix,
RejectedExecutionHandler rejectedExecutionHandler) |
static com.google.common.util.concurrent.ListeningExecutorService |
newShrinkableFixedThreadPool(int maxThreads,
String threadNamePrefix) |
static com.google.common.util.concurrent.ListeningExecutorService |
newShrinkableFixedThreadPool(int nbThreads,
String threadNamePrefix,
int queueCapacity,
RejectedExecutionHandler rejectedExecutionHandler) |
static com.google.common.util.concurrent.ListeningExecutorService |
newShrinkableFixedThreadPool(String threadNamePrefix) |
static com.google.common.util.concurrent.ListeningExecutorService |
newShrinkableFixedThreadPool(String threadNamePrefix,
int queueCapacity,
RejectedExecutionHandler rejectedExecutionHandler) |
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newShrinkableScheduledThreadPool(String threadNamePrefix) |
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newShrinkableScheduledThreadPool(String threadNamePrefix,
RejectedExecutionHandler rejectedExecutionHandler) |
static com.google.common.util.concurrent.ListeningExecutorService |
newSingleThreadExecutor(String threadNamePrefix) |
static com.google.common.util.concurrent.ListeningExecutorService |
newSingleThreadExecutor(String threadNamePrefix,
int queueCapacity,
RejectedExecutionHandler rejectedExecutionHandler) |
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newSingleThreadScheduledExecutor(String threadNamePrefix) |
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newSingleThreadScheduledExecutor(String threadNamePrefix,
RejectedExecutionHandler rejectedExecutionHandler) |
static <T,V> Iterator<? extends Runnable> |
partitions(Iterator<T> input,
Consumer<? super List<T>> consumer) |
static <T> Iterator<? extends Runnable> |
partitions(Iterator<T> input,
Consumer<? super List<T>> consumer,
int partitionSize) |
static <T,V> Iterator<? extends Supplier<V>> |
partitions(Iterator<T> input,
com.google.common.base.Function<? super List<T>,V> function) |
static <T,V> Iterator<? extends Supplier<V>> |
partitions(Iterator<T> input,
com.google.common.base.Function<? super List<T>,V> function,
int partitionSize) |
protected static final org.slf4j.Logger LOGGER
public static final int DEFAULT_LOG_ON_SLOW_QUEUE_MS
public static final int DEFAULT_PARTITION_TASK_SIZE
public static final int DEFAULT_MINIMUM_QUEUE_SIZE
@Deprecated public static final int DEFAULT_SPLIT_TASK_SIZE
public static final RejectedExecutionHandler TIMEOUT_POLICY_1_HOUR
public static final RejectedExecutionHandler DEFAULT_ABORT_POLICY
public static final RejectedExecutionHandler DEFAULT_REJECTION_POLICY
public static final int DEFAULT_QUEUE_CAPACITY
public static final int DEFAULT_NB_CORES
public static final int DEFAULT_ACTIVE_TASKS
public static final int CORE_KEEP_ALIVE_IN_SECONDS
ThreadPoolExecutor,
Constant Field Valuesprotected static boolean allowTryMax
public static com.google.common.util.concurrent.ListeningExecutorService newSingleThreadExecutor(String threadNamePrefix)
public static com.google.common.util.concurrent.ListeningExecutorService newSingleThreadExecutor(String threadNamePrefix, int queueCapacity, RejectedExecutionHandler rejectedExecutionHandler)
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newSingleThreadScheduledExecutor(String threadNamePrefix)
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newSingleThreadScheduledExecutor(String threadNamePrefix, RejectedExecutionHandler rejectedExecutionHandler)
public static ThreadFactory makeDaemonThreadFactory(String threadNamePrefix)
public static int getDefaultNbThreads()
Runtime.availableProcessors()public static com.google.common.util.concurrent.ListeningExecutorService newShrinkableFixedThreadPool(String threadNamePrefix)
public static com.google.common.util.concurrent.ListeningExecutorService newShrinkableFixedThreadPool(int maxThreads,
String threadNamePrefix)
public static com.google.common.util.concurrent.ListeningExecutorService newShrinkableFixedThreadPool(String threadNamePrefix, int queueCapacity, RejectedExecutionHandler rejectedExecutionHandler)
threadNamePrefix - queueCapacity - thr capacity of the queue holding pending runnablerejectedExecutionHandler - ExecutorService relying on daemon threads, closing automatically threads when not used for
some timepublic static com.google.common.util.concurrent.ListeningExecutorService newShrinkableFixedThreadPool(int nbThreads,
String threadNamePrefix,
int queueCapacity,
RejectedExecutionHandler rejectedExecutionHandler)
public static com.google.common.util.concurrent.ListeningExecutorService newShrinkableCachedThreadPool(String threadNamePrefix, RejectedExecutionHandler rejectedExecutionHandler)
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newShrinkableScheduledThreadPool(String threadNamePrefix)
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newShrinkableScheduledThreadPool(String threadNamePrefix, RejectedExecutionHandler rejectedExecutionHandler)
@Deprecated public static RejectedExecutionHandler makeRejectedExecutionHandler(int timeout, TimeUnit unit)
public static <T> List<? extends com.google.common.util.concurrent.ListenableFuture<T>> invokeAll(Collection<? extends Supplier<? extends T>> tasks, com.google.common.util.concurrent.ListeningExecutorService executorService) throws InterruptedException
InterruptedExceptionExecutorService.invokeAll(Collection)public static <T> List<? extends com.google.common.util.concurrent.ListenableFuture<T>> invokeAll(Collection<? extends Callable<? extends T>> tasks, com.google.common.util.concurrent.ListeningExecutorService executorService, long timeout, TimeUnit unit) throws InterruptedException
InterruptedExceptionExecutorService.invokeAll(Collection, long, TimeUnit)public static void executeAllRunnable(Collection<? extends Runnable> tasks, com.google.common.util.concurrent.ListeningExecutorService executorService) throws InterruptedException
Runnable. We do not return a
Collection of Future as if one of the task fails, the whole compution is cancelled. And there is
not timeout mechanismpublic static List<? extends com.google.common.util.concurrent.ListenableFuture<?>> invokeAllRunnable(Collection<? extends Runnable> tasks, com.google.common.util.concurrent.ListeningExecutorService executorService, long timeout, TimeUnit unit) throws InterruptedException
RunnableInterruptedExceptionExecutorService.invokeAll(Collection, long, TimeUnit)public static <T,V> Iterator<? extends Supplier<V>> partitions(Iterator<T> input, com.google.common.base.Function<? super List<T>,V> function)
public static <T,V> Iterator<? extends Supplier<V>> partitions(Iterator<T> input, com.google.common.base.Function<? super List<T>,V> function, int partitionSize)
public static <T,V> Iterator<? extends Runnable> partitions(Iterator<T> input, Consumer<? super List<T>> consumer)
public static <T> Iterator<? extends Runnable> partitions(Iterator<T> input, Consumer<? super List<T>> consumer, int partitionSize)
public static ForkJoinPool newForkJoinPool(String threadPrefix)
public static ForkJoinPool newForkJoinPool(String threadPrefix, int parallelism)
Copyright © 2014–2017 Pivotal Software, Inc.. All rights reserved.