Exemplo n.º 1
0
 /**
  * @return new eager SimpleReact builder configured to run on a separate thread (non-blocking
  *     current thread), sequentially Common free thread Executor from
  */
 public static SimpleReact sequentialCommonBuilder() {
   return SimpleReact.builder()
       .async(false)
       .executor(ThreadPools.getCommonFreeThread())
       .retrier(
           RetryBuilder.getDefaultInstance().withScheduler(ThreadPools.getCommonFreeThreadRetry()))
       .build();
 }
Exemplo n.º 2
0
 /**
  * @return new eager SimpleReact builder configured to run on a separate thread (non-blocking
  *     current thread), sequentially New ForkJoinPool will be created
  */
 public static SimpleReact sequentialBuilder() {
   return SimpleReact.builder()
       .async(false)
       .executor(new ForkJoinPool(1))
       .retrier(
           RetryBuilder.getDefaultInstance().withScheduler(Executors.newScheduledThreadPool(1)))
       .build();
 }
Exemplo n.º 3
0
 /**
  * @return new eager SimpleReact builder configured with standard parallel executor By default
  *     this is the ForkJoinPool common instance but is configurable in the ThreadPools class
  * @see ThreadPools#getStandard() see RetryBuilder#getDefaultInstance()
  */
 public static SimpleReact parallelCommonBuilder() {
   return SimpleReact.builder()
       .executor(ThreadPools.getStandard())
       .async(true)
       .retrier(
           RetryBuilder.getDefaultInstance().withScheduler(ThreadPools.getCommonFreeThreadRetry()))
       .build();
 }
Exemplo n.º 4
0
 /**
  * Construct a new SimpleReact builder, with a new task executor and retry executor with
  * configured number of threads
  *
  * @param parallelism Number of threads task executor should have
  * @return eager SimpleReact instance
  */
 public static SimpleReact parallelBuilder(int parallelism) {
   return SimpleReact.builder()
       .executor(new ForkJoinPool(parallelism))
       .retrier(new RetryBuilder().parallelism(parallelism))
       .build();
 }
Exemplo n.º 5
0
 /**
  * Trigger a lazy stream as a task on the provided Executor
  *
  * @param e Executor service to trigger lazy stream on (Stream CompletableFutures will use
  *     Executor associated with this Stage may not be the same one).
  */
 default void runOn(Executor e) {
   SimpleReact reactor = SequentialElasticPools.simpleReact.nextReactor();
   reactor
       .react(() -> run(new NonCollector()))
       .peek(n -> SequentialElasticPools.simpleReact.populate(reactor));
 }