diff --git a/README.md b/README.md
index 4aa6620..b5c03a4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.javaflow/net.tascalate.javaflow.extras.svg)](https://search.maven.org/artifact/net.tascalate.javaflow/net.tascalate.javaflow.extras/2.3.0/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-javaflow-extras.svg)](https://github.com/vsilaev/tascalate-javaflow-extras/releases/tag/2.3.0) [![license](https://img.shields.io/github/license/vsilaev/tascalate-javaflow-extras.svg)](https://github.com/vsilaev/tascalate-javaflow-extras/blob/master/LICENSE)
+[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.javaflow/net.tascalate.javaflow.extras.svg)](https://search.maven.org/artifact/net.tascalate.javaflow/net.tascalate.javaflow.extras/2.3.1/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-javaflow-extras.svg)](https://github.com/vsilaev/tascalate-javaflow-extras/releases/tag/2.3.1) [![license](https://img.shields.io/github/license/vsilaev/tascalate-javaflow-extras.svg)](https://github.com/vsilaev/tascalate-javaflow-extras/blob/master/LICENSE)
# Tascalate JavaFlow Extras
Continuations / CoRoutines for Java 8+. This library is an add-on to [Tascalate Javaflow](https://github.com/vsilaev/tascalate-javaflow) continuations library. It provides suspendable version of java.util.Stream, java.util.Iterator, java.util.function.* and helper classes to work with continuations.
diff --git a/pom.xml b/pom.xml
index 10fd499..a7f1543 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
net.tascalate.javaflow
net.tascalate.javaflow.extras
- 2.3.0
+ 2.3.1
jar
diff --git a/src/main/java/net/tascalate/javaflow/Continuations.java b/src/main/java/net/tascalate/javaflow/Continuations.java
index 2721611..e7e656b 100644
--- a/src/main/java/net/tascalate/javaflow/Continuations.java
+++ b/src/main/java/net/tascalate/javaflow/Continuations.java
@@ -287,7 +287,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param coroutine a coroutine that yields multiple results
* @param action a continuable action to perform on the values emitted
*/
- public static @continuable void forEach$(Continuation coroutine, SuspendableConsumer super T> action) {
+ public static @continuable void forEach$(Continuation coroutine, SuspendableConsumer super T> action) {
forEach$(coroutine, false, action);
}
@@ -301,7 +301,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param useCurrentValue should the current coroutine result be used as a first value to process
* @param action a continuable action to perform on the values emitted
*/
- public static @continuable void forEach$(Continuation coroutine, boolean useCurrentValue, SuspendableConsumer super T> action) {
+ public static @continuable void forEach$(Continuation coroutine, boolean useCurrentValue, SuspendableConsumer super T> action) {
try (CloseableIterator iter = iteratorOf(coroutine, useCurrentValue)) {
forEach$(iter, action);
}
@@ -315,7 +315,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param coroutine a coroutine that yields multiple results
* @param action a continuable action to perform on the values emitted
*/
- public static @continuable void forEach$(SuspendableRunnable coroutine, SuspendableConsumer super T> action) {
+ public static @continuable void forEach$(SuspendableRunnable coroutine, SuspendableConsumer super T> action) {
forEach$(create(coroutine), false, action);
}
@@ -336,7 +336,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param action a non-continuable function that is applied to values emitted and provides argument to
* resume coroutine.
*/
- public static @continuable void forEachReply$(Continuation coroutine, SuspendableFunction super T, ?> action) {
+ public static @continuable void forEachReply$(Continuation coroutine, SuspendableFunction super T, ?> action) {
forEachReply$(coroutine, false, action);
}
@@ -358,7 +358,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param action a non-continuable function that is applied to values emitted and provides argument to
* resume coroutine.
*/
- public static @continuable void forEachReply$(Continuation coroutine, boolean useCurrentValue, SuspendableFunction super T, ?> action) {
+ public static @continuable void forEachReply$(Continuation coroutine, boolean useCurrentValue, SuspendableFunction super T, ?> action) {
Continuation cc = coroutine;
try {
Object param = null;
@@ -394,7 +394,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param action a non-continuable function that is applied to values emitted and provides argument to
* resume coroutine.
*/
- public static @continuable void forEachReply$(SuspendableRunnable coroutine, SuspendableFunction super T, ?> action) {
+ public static @continuable void forEachReply$(SuspendableRunnable coroutine, SuspendableFunction super T, ?> action) {
forEachReply$(create(coroutine), action);
}
@@ -408,7 +408,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param stream the stream to perform an action on
* @param action a continuable action to perform on the elements
*/
- public static @continuable void forEach$(Stream stream, SuspendableConsumer super T> action) {
+ public static @continuable void forEach$(Stream stream, SuspendableConsumer super T> action) {
forEach$(stream.iterator(), action);
}
@@ -422,7 +422,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param iterable the iterable to perform an action on
* @param action a continuable action to perform on the elements
*/
- public static @continuable void forEach$(Iterable iterable, SuspendableConsumer super T> action) {
+ public static @continuable void forEach$(Iterable iterable, SuspendableConsumer super T> action) {
Iterator iter = iterable.iterator();
try (CloseableIterator closeable = asCloseable(iter)) {
forEach$(iter, action);
@@ -439,7 +439,7 @@ public static void forEachReply(SuspendableRunnable coroutine, Function su
* @param iterator the iterator to perform an action on
* @param action a continuable action to perform on the elements
*/
- private @continuable static void forEach$(Iterator iterator, SuspendableConsumer super T> action) {
+ private static @continuable void forEach$(Iterator iterator, SuspendableConsumer super T> action) {
while (iterator.hasNext()) {
action.accept(iterator.next());
}
diff --git a/src/main/java/net/tascalate/javaflow/SuspendableStream.java b/src/main/java/net/tascalate/javaflow/SuspendableStream.java
index 15a078a..37635a9 100644
--- a/src/main/java/net/tascalate/javaflow/SuspendableStream.java
+++ b/src/main/java/net/tascalate/javaflow/SuspendableStream.java
@@ -138,20 +138,22 @@ public Option produce() {
public static SuspendableStream iterate(T seed, UnaryOperator f) {
return new SuspendableStream<>(new RootProducer() {
- Option current = Option.none();
+ Option current = null;
@Override
public Option produce() {
- return current.exists() ? current.map(f) : Option.some(seed);
+ current = null == current ? Option.some(seed) : current.map(f);
+ return current;
}
});
}
public static SuspendableStream iterate$(T seed, SuspendableUnaryOperator f) {
return new SuspendableStream<>(new RootProducer() {
- Option current = Option.none();
+ Option current = null;
@Override
public Option produce() {
- return current.exists() ? current.map$(f) : Option.some(seed);
+ current = null == current ? Option.some(seed) : current.map$(f);
+ return current;
}
});
}