Top Inners Fields Constructors Methods
org.osgi.util.pushstream

pack-priv abstract Class AbstractPushStreamImpl<T>

extends Object
implements PushStream<T>
Class Inheritance
All Implemented Interfaces
org.osgi.util.pushstream.PushStream, java.lang.AutoCloseable
Known Direct Subclasses
org.osgi.util.pushstream.IntermediatePushStreamImpl, org.osgi.util.pushstream.UnbufferedPushStreamImpl
Static Imports
java.util.Collections.emptyList, java.util.concurrent.TimeUnit.NANOSECONDS, java.util.stream.Collector.Characteristics.CONCURRENT, .Collector.Characteristics.IDENTITY_FINISH, org.osgi.util.pushstream.AbstractPushStreamImpl.State.BUILDING, .AbstractPushStreamImpl.State.CLOSED, .AbstractPushStreamImpl.State.STARTED, .PushEventConsumer.ABORT, .PushEventConsumer.CONTINUE

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static enum

Field Summary

Modifier and TypeField and Description
protected final AtomicReference<AbstractPushStreamImpl.State>
private final Function<T, T>
protected final AtomicReference<PushEventConsumer<T>>
protected final AtomicReference<Runnable>
protected final AtomicReference<Consumer<? super Throwable>>
protected final PromiseFactory
protected final PushStreamProvider

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public PushStream<T>
adjustBackPressure(LongUnaryOperator adjustment)

Implements org.osgi.util.pushstream.PushStream.adjustBackPressure.

Changes the back-pressure propagated by this pipeline stage.

public PushStream<T>
adjustBackPressure(ToLongBiFunction<T, Long> adjustment)

Implements org.osgi.util.pushstream.PushStream.adjustBackPressure.

Changes the back-pressure propagated by this pipeline stage.

private <R> long
aggregateAndForward(Function<Collection<T>, R> f, AbstractPushStreamImpl<R> eventStream, PushEvent<? extends T> event, Queue<T> queue)

private <R> void
aggregateAndForward(BiFunction<Long, Collection<T>, R> f, AbstractPushStreamImpl<R> eventStream, PushEvent<? extends T> event, Queue<T> queue, Executor executor, long elapsed)

public Promise<Boolean>
allMatch(Predicate<? super T> predicate)

Implements org.osgi.util.pushstream.PushStream.allMatch.

Closes the channel and resolve the promise with false when the predicate does not matches a pay load.

public Promise<Boolean>
anyMatch(Predicate<? super T> predicate)

Implements org.osgi.util.pushstream.PushStream.anyMatch.

Close the channel and resolve the promise with true when the predicate matches a payload.

public <R> PushStream<R>
asyncMap(int
number of simultaneous promises to use
n
,
int
Nr of ms/promise that is queued back pressure
delay
,
Function<? super T, Promise<? extends R>>
The mapping function
mapper
)

Implements org.osgi.util.pushstream.PushStream.asyncMap.

Asynchronously map the payload values.

protected abstract boolean
public PushStream<T>
buffer()

Implements org.osgi.util.pushstream.PushStream.buffer.

Buffer the events in a queue using default values for the queue size and other behaviors.

public <U extends BlockingQueue<PushEvent<? extends T>>> PushStreamBuilder<T, U>
buildBuffer()

Implements org.osgi.util.pushstream.PushStream.buildBuffer.

Build a buffer to enqueue events in a queue using custom values for the queue size and other behaviors.

pack-priv void
check(AtomicLong lastTime, long timeout)

public void
close()

Implements org.osgi.util.pushstream.PushStream.close.

Close this PushStream by sending an event of type PushEvent.EventType#CLOSE downstream.

protected boolean
close(PushEvent<T> event)

protected boolean
close(PushEvent<T> event, boolean sendDownStreamEvent)

public <R> PushStream<R>
coalesce(Function<? super T, Optional<R>> accumulator)

Implements org.osgi.util.pushstream.PushStream.coalesce.

Coalesces a number of events into a new type of event.

public <R> PushStream<R>
coalesce(int count, Function<Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.coalesce.

Coalesces a number of events into a new type of event.

public <R> PushStream<R>
coalesce(IntSupplier count, Function<Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.coalesce.

Coalesces a number of events into a new type of event.

public <R, A> Promise<R>
collect(Collector<? super T, A, R> collector)

Implements org.osgi.util.pushstream.PushStream.collect.

See Stream.

public Promise<Long>
public PushStream<T>
distinct()

Implements org.osgi.util.pushstream.PushStream.distinct.

Remove any duplicates.

public PushStream<T>
filter(Predicate<? super T>
The predicate that is tested (not null)
predicate
)

Implements org.osgi.util.pushstream.PushStream.filter.

Only pass events downstream when the predicate tests true.

public Promise<Optional<T>>
findAny()

Implements org.osgi.util.pushstream.PushStream.findAny.

Close the channel and resolve the promise with the first element.

public Promise<Optional<T>>
findFirst()

Implements org.osgi.util.pushstream.PushStream.findFirst.

Close the channel and resolve the promise with the first element.

public <R> PushStream<R>
flatMap(Function<? super T, ? extends PushStream<? extends R>>
The flat map function
mapper
)

Implements org.osgi.util.pushstream.PushStream.flatMap.

Flat map the payload value (turn one event into 0..n events of potentially another type).

public Promise<Void>
forEach(Consumer<? super T>
The action to perform
action
)

Implements org.osgi.util.pushstream.PushStream.forEach.

Execute the action for each event received until the channel is closed.

public Promise<Long>
forEachEvent(PushEventConsumer<? super T> action)

Implements org.osgi.util.pushstream.PushStream.forEachEvent.

Pass on each event to another consumer until the stream is closed.

public PushStream<T>
fork(int
number of simultaneous background threads to use
n
,
int
Nr of ms/thread that is queued back pressure
delay
,
Executor
an executor to use for the background threads.
ex
)

Implements org.osgi.util.pushstream.PushStream.fork.

Execute the downstream events in up to n background threads.

protected Queue<T>
private <R> Runnable
getWindowTask(AbstractPushStreamImpl<R> eventStream, BiFunction<Long, Collection<T>, R> f, Supplier<Duration> time, IntSupplier maxEvents, Object lock, long expectedCounter, AtomicReference<Queue<T>> queueRef, AtomicLong timestamp, AtomicLong counter, AtomicLong previousWindowSize, Executor executor)

protected long
handleEvent(PushEvent<? extends T> event)

public PushStream<T>
limit(long
Maximum number of elements has been received
maxSize
)

Implements org.osgi.util.pushstream.PushStream.limit.

Automatically close the channel after the maxSize number of elements is received.

public PushStream<T>
limit(Duration
The maximum time that the stream should remain open
maxTime
)

Implements org.osgi.util.pushstream.PushStream.limit.

Automatically close the channel after the given amount of time has elapsed.

public <R> PushStream<R>
map(Function<? super T, ? extends R>
The map function
mapper
)

Implements org.osgi.util.pushstream.PushStream.map.

Map a payload value.

public Promise<Optional<T>>
max(Comparator<? super T> comparator)

Implements org.osgi.util.pushstream.PushStream.max.

See Stream.

public PushStream<T>
merge(PushEventSource<? extends T>
The source to merge in.
source
)

Implements org.osgi.util.pushstream.PushStream.merge.

Merge in the events from another source.

public PushStream<T>
merge(PushStream<? extends T>
The source to merge in.
source
)

Implements org.osgi.util.pushstream.PushStream.merge.

Merge in the events from another PushStream.

public Promise<Optional<T>>
min(Comparator<? super T> comparator)

Implements org.osgi.util.pushstream.PushStream.min.

See Stream.

public Promise<Boolean>
noneMatch(Predicate<? super T> predicate)

Implements org.osgi.util.pushstream.PushStream.noneMatch.

Closes the channel and resolve the promise with false when the predicate matches any pay load.

public PushStream<T>
onClose(Runnable
Will be called on close
closeHandler
)

Implements org.osgi.util.pushstream.PushStream.onClose.

Provide a handler that must be run after the PushStream is closed.

public PushStream<T>
onError(Consumer<? super Throwable>
Will be called on an error event
closeHandler
)

Implements org.osgi.util.pushstream.PushStream.onError.

Provide a handler that will be called if the PushStream is closed with an event of type PushEvent.EventType#ERROR.

public Promise<T>
reduce(T
The identity/begin value
identity
,
BinaryOperator<T>
The accumulator
accumulator
)

Implements org.osgi.util.pushstream.PushStream.reduce.

Standard reduce, see Stream.

public Promise<Optional<T>>
reduce(BinaryOperator<T>
The accumulator
accumulator
)

Implements org.osgi.util.pushstream.PushStream.reduce.

Standard reduce without identity, so the return is an Optional.

public <U> Promise<U>
reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U>
combines two U's into one U (for example, combine two lists)
combiner
)

Implements org.osgi.util.pushstream.PushStream.reduce.

Standard reduce with identity, accumulator and combiner.

public PushStream<T>
sequential()

Implements org.osgi.util.pushstream.PushStream.sequential.

Ensure that any events are delivered sequentially.

public PushStream<T>
skip(long
number of elements to skip
n
)

Implements org.osgi.util.pushstream.PushStream.skip.

Skip a number of events in the channel.

public PushStream<T>
sorted()

Implements org.osgi.util.pushstream.PushStream.sorted.

Sorted the elements, assuming that T extends Comparable.

public PushStream<T>
sorted(Comparator<? super T> comparator)

Implements org.osgi.util.pushstream.PushStream.sorted.

Sorted the elements with the given comparator.

public PushStream<T>[]
split(Predicate<? super T>...
the predicates to test
predicates
)

Implements org.osgi.util.pushstream.PushStream.split.

Split the events to different streams based on a predicate.

public PushStream<T>
timeout(Duration
The length of time that the stream should remain open when no events are being received.
maxTime
)

Implements org.osgi.util.pushstream.PushStream.timeout.

Automatically fail the channel if no events are received for the indicated length of time.

public Promise<Object[]>
toArray()

Implements org.osgi.util.pushstream.PushStream.toArray.

Collect the payloads in an Object array after the channel is closed.

public <A> Promise<A[]>
toArray(IntFunction<A[]>
A function which returns an array into which the payloads are stored.
generator
)

Implements org.osgi.util.pushstream.PushStream.toArray.

Collect the payloads in an Object array after the channel is closed.

private void
protected abstract void
public <R> PushStream<R>
window(Duration time, Function<Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.window.

Buffers a number of events over a fixed time interval and then forwards the events to an accumulator function.

public <R> PushStream<R>
window(Duration time, Executor executor, Function<Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.window.

Buffers a number of events over a fixed time interval and then forwards the events to an accumulator function.

public <R> PushStream<R>
window(Supplier<Duration> time, IntSupplier maxEvents, BiFunction<Long, Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.window.

Buffers a number of events over a variable time interval and then forwards the events to an accumulator function.

public <R> PushStream<R>
window(Supplier<Duration> time, IntSupplier maxEvents, Executor ex, BiFunction<Long, Collection<T>, R> f)

Implements org.osgi.util.pushstream.PushStream.window.

Buffers a number of events over a variable time interval and then forwards the events to an accumulator function.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait