public class LazyReact extends java.lang.Object implements ReactBuilder
Constructor and Description |
---|
LazyReact()
Construct a LazyReact builder using standard thread pool.
|
LazyReact(java.util.concurrent.Executor executor)
Construct a LazyReact builder with provided Executor
|
LazyReact(java.util.concurrent.Executor currentThreadExecutor,
com.nurkiewicz.asyncretry.AsyncRetryExecutor withScheduler,
boolean async,
MaxActive maxActive2) |
LazyReact(java.util.concurrent.Executor executor,
com.nurkiewicz.asyncretry.RetryExecutor retrier,
java.lang.Boolean async,
MaxActive maxActive,
java.util.concurrent.Executor pub,
boolean streamOfFutures,
boolean objectPoolingActive,
boolean autoOptimize,
boolean autoMemoize,
com.aol.cyclops.functions.caching.Cacheable memoizeCache) |
LazyReact(int threadPoolSize,
int maxActiveTasks)
LazyReact builder with a new TaskExecutor with threads determined by threadPoolSize
Max concurrent tasks is determined by concurrency
|
Modifier and Type | Method and Description |
---|---|
LazyReact |
async()
Start any created Streams in asyncrhonous mode - that is tasks will be submited to an Executor to be run.
|
LazyReact |
autoMemoizeOn(com.aol.cyclops.functions.caching.Cacheable memoizeCache) |
LazyReact |
autoOptimizeOff()
Turn off automatic threading management.
|
LazyReact |
autoOptimizeOn()
Turn on automatic threading optimization.
|
<U> LazyFutureStream<U> |
construct(java.util.stream.Stream s) |
<U> LazyFutureStream<U> |
constructFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> s) |
<R> LazyFutureStream<R> |
from(java.util.Collection<R> collection)
Start a reactive flow from a Collection using an Iterator
|
<U> LazyFutureStream<U> |
from(java.util.concurrent.CompletableFuture<U>... cf) |
<U> LazyFutureStream<U> |
from(java.util.concurrent.CompletableFuture<U> cf) |
LazyFutureStream<java.lang.Double> |
from(java.util.stream.DoubleStream stream)
Start a reactive dataflow from a stream.
|
LazyFutureStream<java.lang.Integer> |
from(java.util.stream.IntStream stream)
Start a reactive dataflow from a stream.
|
<U> LazyFutureStream<U> |
from(java.util.Iterator<U> iterator)
Start a reactive flow from a JDK Iterator
|
LazyFutureStream<java.lang.Long> |
from(java.util.stream.LongStream stream)
Start a reactive dataflow from a stream.
|
<U> LazyFutureStream<U> |
from(java.util.stream.Stream<U> stream) |
<U> LazyFutureStream<U> |
fromIterable(java.lang.Iterable<U> iter) |
<U> LazyFutureStream<U> |
fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream) |
boolean |
isAsync() |
<U> LazyFutureStream<U> |
iterateInfinitely(U seed,
java.util.function.UnaryOperator<U> f)
Iterate infinitely using the supplied seed and function
|
LazyReact |
objectPoolingOff()
Turn objectPooling off for any Streams created by the returned LazyReact builder.
|
LazyReact |
objectPoolingOn()
Turn objectPooling on for any Streams created by the returned LazyReact builder
This improves performance for Streams with very large numbers of elements, by reusing
Future instances.
|
<U> LazyFutureStream<U> |
of(U... array) |
static LazyReact |
parallelBuilder() |
static LazyReact |
parallelBuilder(int parallelism)
Construct a new LazyReact builder, with a new task executor and retry
executor with configured number of threads
|
static LazyReact |
parallelCommonBuilder() |
LazyFutureStream<java.lang.Integer> |
range(int startInclusive,
int endExclusive) |
<U> LazyFutureStream<U> |
react(java.util.Collection<java.util.function.Supplier<U>> actions) |
<U> LazyFutureStream<U> |
react(java.util.Iterator<java.util.function.Supplier<U>> actions) |
<U> LazyFutureStream<U> |
react(java.util.stream.Stream<java.util.function.Supplier<U>> actions) |
<U> LazyFutureStream<U> |
react(java.util.function.Supplier<U>... actions) |
protected <U> LazyFutureStream<U> |
reactI(java.util.function.Supplier<U>... actions) |
<U> LazyFutureStream<U> |
reactInfinitely(java.util.function.Supplier<U> s)
Generate an infinite reactive flow.
|
<U> LazyFutureStream<U> |
reactInfinitelyAsync(java.util.function.Supplier<U> s)
Generate an infinite reactive flow.
|
<U> LazyFutureStream<U> |
reactIterable(java.lang.Iterable<java.util.function.Supplier<U>> actions) |
static LazyReact |
sequentialBuilder() |
static LazyReact |
sequentialCommonBuilder() |
static LazyReact |
sequentialCurrentBuilder() |
LazyReact |
sync()
Start any created Streams in syncrhonous mode - that is tasks will be executed on the calling thread
|
public LazyReact()
ThreadPools.getStandard()
public LazyReact(java.util.concurrent.Executor executor)
executor
- Executor to usepublic LazyReact(int threadPoolSize, int maxActiveTasks)
threadPoolSize
- maxActiveTasks
- public LazyReact(java.util.concurrent.Executor executor, com.nurkiewicz.asyncretry.RetryExecutor retrier, java.lang.Boolean async, MaxActive maxActive, java.util.concurrent.Executor pub, boolean streamOfFutures, boolean objectPoolingActive, boolean autoOptimize, boolean autoMemoize, com.aol.cyclops.functions.caching.Cacheable memoizeCache)
executor
- Task Executor for concurrent tasksretrier
- Async Retrierasync
- If true each task will be submitted to an executor servicepublic LazyReact(java.util.concurrent.Executor currentThreadExecutor, com.nurkiewicz.asyncretry.AsyncRetryExecutor withScheduler, boolean async, MaxActive maxActive2)
public LazyReact autoMemoizeOn(com.aol.cyclops.functions.caching.Cacheable memoizeCache)
public boolean isAsync()
public <U> LazyFutureStream<U> from(java.util.concurrent.CompletableFuture<U> cf)
public <U> LazyFutureStream<U> from(java.util.concurrent.CompletableFuture<U>... cf)
public <U> LazyFutureStream<U> construct(java.util.stream.Stream s)
public <U> LazyFutureStream<U> constructFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> s)
public LazyReact objectPoolingOn()
return new LazyReact()
.objectPoolingOn()
.range(0,5_000_000_000)
.map(this::process)
.forEach(System.out::println);
public LazyReact objectPoolingOff()
LazyReact react;
react.objectPoolingOff()
.range(0,5_000)
.map(this::process)
.forEach(System.out::println);
public LazyReact autoOptimizeOn()
new LazyReact().autoOptimizeOn()
.range(0, 1_000_000)
.map(i->i+2)
.map(i->Thread.currentThread().getId())
.peek(System.out::println)
.runOnCurrent();
public LazyReact autoOptimizeOff()
LazyReact react;
react.autoOptimizeOff()
.range(0, 1_000_000)
.map(i->i+2)
.map(i->Thread.currentThread().getId())
.peek(System.out::println)
.runOnCurrent();
public LazyReact async()
public LazyReact sync()
public LazyFutureStream<java.lang.Integer> range(int startInclusive, int endExclusive)
public <U> LazyFutureStream<U> fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
@SafeVarargs public final <U> LazyFutureStream<U> react(java.util.function.Supplier<U>... actions)
public <U> LazyFutureStream<U> from(java.util.stream.Stream<U> stream)
public <U> LazyFutureStream<U> react(java.util.Collection<java.util.function.Supplier<U>> actions)
protected <U> LazyFutureStream<U> reactI(java.util.function.Supplier<U>... actions)
public <U> LazyFutureStream<U> fromIterable(java.lang.Iterable<U> iter)
public <U> LazyFutureStream<U> react(java.util.stream.Stream<java.util.function.Supplier<U>> actions)
public <U> LazyFutureStream<U> react(java.util.Iterator<java.util.function.Supplier<U>> actions)
public <U> LazyFutureStream<U> reactIterable(java.lang.Iterable<java.util.function.Supplier<U>> actions)
public static LazyReact parallelBuilder()
public static LazyReact parallelBuilder(int parallelism)
parallelism
- Number of threads task executor should havepublic static LazyReact parallelCommonBuilder()
see RetryBuilder#getDefaultInstance()
public static LazyReact sequentialBuilder()
public static LazyReact sequentialCommonBuilder()
public static LazyReact sequentialCurrentBuilder()
public <U> LazyFutureStream<U> reactInfinitely(java.util.function.Supplier<U> s)
s
- Supplier to generate the infinite flowSimpleReact Queue for a way to create a more managable infinit flow
public <U> LazyFutureStream<U> reactInfinitelyAsync(java.util.function.Supplier<U> s)
s
- Supplier to generate the infinite flowSimpleReact Queue for a way to create a more managable infinit flow
public <U> LazyFutureStream<U> iterateInfinitely(U seed, java.util.function.UnaryOperator<U> f)
seed
- Initial valuef
- Function that performs the iterationpublic <U> LazyFutureStream<U> from(java.util.Iterator<U> iterator)
iterator
- SimpleReact will iterate over this iterator concurrently to start the reactive dataflowpublic <R> LazyFutureStream<R> from(java.util.Collection<R> collection)
collection
- - Collection SimpleReact will iterate over at the start of the flowpublic LazyFutureStream<java.lang.Integer> from(java.util.stream.IntStream stream)
stream
- that will be used to drive the reactive dataflowpublic LazyFutureStream<java.lang.Double> from(java.util.stream.DoubleStream stream)
stream
- that will be used to drive the reactive dataflowpublic LazyFutureStream<java.lang.Long> from(java.util.stream.LongStream stream)
stream
- that will be used to drive the reactive dataflowpublic <U> LazyFutureStream<U> of(U... array)