public abstract class StreamCore extends java.lang.Object
Represents a common base for publish-subscribe deterministic channels.
- Type for values to pass through the channelsModifiers | Name | Description |
---|---|---|
protected DataflowVariable<T> |
first |
|
protected java.util.concurrent.atomic.AtomicReference<StreamCore<T>> |
rest |
|
protected java.util.Collection<MessageStream> |
wheneverBoundListeners |
A collection of listeners who need to be informed each time the stream is bound to a value |
Constructor and description |
---|
protected StreamCore
(DataflowVariable<T> first) Creates an empty stream |
protected StreamCore
(DataflowVariable<T> first, groovy.lang.Closure toBeApplied) Creates a stream while applying the supplied initialization closure to it |
protected StreamCore
(DataflowVariable<T> first, java.util.Collection<MessageStream> wheneverBoundListeners, java.util.Collection<DataflowChannelListener<T>> updateListeners) |
Type | Name and description |
---|---|
void |
addUpdateListener(DataflowChannelListener<T> updateListener) |
private void |
addUpdateListeners(java.util.Collection<DataflowChannelListener<T>> updateListeners) |
java.lang.String |
appendingString() |
StreamCore<T> |
apply(groovy.lang.Closure closure) Calls the supplied closure with the stream as a parameter |
private void |
bind(T value) |
protected StreamCore<T> |
createNewStream() A factory method to create new instances of the correct class when needed |
void |
decrementParties() Decreases the number of parties required to perform the data exchange |
static T |
eos() |
boolean |
equals(java.lang.Object obj) |
private static T |
eval(java.lang.Object valueOrDataflowVariable) |
FList<T> |
filter(groovy.lang.Closure filterClosure) Builds a filtered stream using the supplied filter closure |
private void |
filter(StreamCore<T> rest, groovy.lang.Closure filterClosure, StreamCore<T> result) |
StreamCore<T> |
generate(T seed, groovy.lang.Closure generator, groovy.lang.Closure condition) Populates the stream with generated values |
private void |
generateNext(T value, StreamCore<T> stream, groovy.lang.Closure generator, groovy.lang.Closure condition) |
T |
getFirst() Retrieved the first element in the stream, blocking until a value is available |
DataflowVariable<T> |
getFirstDFV() |
FList<T> |
getRest() Retrieves a DataflowStream representing the rest of this Stream after removing the first element |
int |
hashCode() |
private DataflowExpression<T> |
hookWheneverBoundListeners(DataflowExpression<T> expr) Hooks the registered when bound handlers to the supplied dataflow expression |
void |
incrementParties() Increases the number of parties required to perform the data exchange |
boolean |
isEmpty() Indicates, whether the first element in the stream is an eos |
java.util.Iterator<T> |
iterator() Builds an iterator to iterate over the stream |
StreamCore<T> |
leftShift(DataflowReadChannel<T> ref) Adds a dataflow variable value to the stream, once the value is available |
StreamCore<T> |
leftShift(T value) Adds a value to the stream |
FList<java.lang.Object> |
map(groovy.lang.Closure mapClosure) Builds a modified stream using the supplied map closure |
private void |
map(FList<T> rest, groovy.lang.Closure mapClosure, StreamCore<java.lang.Object> result) |
T |
reduce(groovy.lang.Closure reduceClosure) Reduces all elements in the stream using the supplied closure |
T |
reduce(T seed, groovy.lang.Closure reduceClosure) Reduces all elements in the stream using the supplied closure |
private T |
reduce(T current, FList<T> rest, groovy.lang.Closure reduceClosure) |
void |
wheneverBound(groovy.lang.Closure closure) |
void |
wheneverBound(MessageStream stream) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
A collection of listeners who need to be informed each time the stream is bound to a value
Creates an empty stream
first
- The variable to store as the head of the streamCreates a stream while applying the supplied initialization closure to it
first
- The variable to store as the head of the streamtoBeApplied
- The closure to use for initializationCalls the supplied closure with the stream as a parameter
closure
- The closure to callA factory method to create new instances of the correct class when needed
Decreases the number of parties required to perform the data exchange
Builds a filtered stream using the supplied filter closure
filterClosure
- The closure to decide on inclusion of elementsPopulates the stream with generated values
seed
- The initial element to evaluate and add as the first value of the streamgenerator
- A closure generating stream elements from the previous valuescondition
- A closure indicating whether the generation should continue based on the last generated valueRetrieved the first element in the stream, blocking until a value is available
Retrieves a DataflowStream representing the rest of this Stream after removing the first element
Hooks the registered when bound handlers to the supplied dataflow expression
expr
- The expression to hook all the when bound listeners toIncreases the number of parties required to perform the data exchange
Indicates, whether the first element in the stream is an eos
Builds an iterator to iterate over the stream
Adds a dataflow variable value to the stream, once the value is available
ref
- The DataflowVariable to check for valueAdds a value to the stream
value
- The value to addBuilds a modified stream using the supplied map closure
mapClosure
- The closure to transform elementsReduces all elements in the stream using the supplied closure
reduceClosure
- The closure to reduce elements of the stream gradually into an accumulator. The accumulator is seeded with the first stream element.Reduces all elements in the stream using the supplied closure
reduceClosure
- The closure to reduce elements of the stream gradually into an accumulator.seed
- The value to initialize the accumulator with.Copyright © 2008–2014 Václav Pech. All Rights Reserved.