Skip to content

Commit

Permalink
Fix error in SuspendableStream.iterate; preparing next release
Browse files Browse the repository at this point in the history
  • Loading branch information
vsilaev committed Sep 11, 2018
1 parent a0ca413 commit 8f95c15
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.tascalate.javaflow</groupId>
<artifactId>net.tascalate.javaflow.extras</artifactId>
<version>2.3.0</version>
<version>2.3.1</version>
<packaging>jar</packaging>

<parent>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/tascalate/javaflow/Continuations.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public static <T> 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<T> void forEach$(Continuation coroutine, SuspendableConsumer<? super T> action) {
public static @continuable <T> void forEach$(Continuation coroutine, SuspendableConsumer<? super T> action) {
forEach$(coroutine, false, action);
}

Expand All @@ -301,7 +301,7 @@ public static <T> 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<T> void forEach$(Continuation coroutine, boolean useCurrentValue, SuspendableConsumer<? super T> action) {
public static @continuable <T> void forEach$(Continuation coroutine, boolean useCurrentValue, SuspendableConsumer<? super T> action) {
try (CloseableIterator<T> iter = iteratorOf(coroutine, useCurrentValue)) {
forEach$(iter, action);
}
Expand All @@ -315,7 +315,7 @@ public static <T> 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<T> void forEach$(SuspendableRunnable coroutine, SuspendableConsumer<? super T> action) {
public static @continuable <T> void forEach$(SuspendableRunnable coroutine, SuspendableConsumer<? super T> action) {
forEach$(create(coroutine), false, action);
}

Expand All @@ -336,7 +336,7 @@ public static <T> 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<T> void forEachReply$(Continuation coroutine, SuspendableFunction<? super T, ?> action) {
public static @continuable <T> void forEachReply$(Continuation coroutine, SuspendableFunction<? super T, ?> action) {
forEachReply$(coroutine, false, action);
}

Expand All @@ -358,7 +358,7 @@ public static <T> 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<T> void forEachReply$(Continuation coroutine, boolean useCurrentValue, SuspendableFunction<? super T, ?> action) {
public static @continuable <T> void forEachReply$(Continuation coroutine, boolean useCurrentValue, SuspendableFunction<? super T, ?> action) {
Continuation cc = coroutine;
try {
Object param = null;
Expand Down Expand Up @@ -394,7 +394,7 @@ public static <T> 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<T> void forEachReply$(SuspendableRunnable coroutine, SuspendableFunction<? super T, ?> action) {
public static @continuable <T> void forEachReply$(SuspendableRunnable coroutine, SuspendableFunction<? super T, ?> action) {
forEachReply$(create(coroutine), action);
}

Expand All @@ -408,7 +408,7 @@ public static <T> 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<T> void forEach$(Stream<T> stream, SuspendableConsumer<? super T> action) {
public static @continuable <T> void forEach$(Stream<T> stream, SuspendableConsumer<? super T> action) {
forEach$(stream.iterator(), action);
}

Expand All @@ -422,7 +422,7 @@ public static <T> 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<T> void forEach$(Iterable<T> iterable, SuspendableConsumer<? super T> action) {
public static @continuable <T> void forEach$(Iterable<T> iterable, SuspendableConsumer<? super T> action) {
Iterator<T> iter = iterable.iterator();
try (CloseableIterator<T> closeable = asCloseable(iter)) {
forEach$(iter, action);
Expand All @@ -439,7 +439,7 @@ public static <T> 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 <T> void forEach$(Iterator<T> iterator, SuspendableConsumer<? super T> action) {
private static @continuable <T> void forEach$(Iterator<T> iterator, SuspendableConsumer<? super T> action) {
while (iterator.hasNext()) {
action.accept(iterator.next());
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/tascalate/javaflow/SuspendableStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,22 @@ public Option<T> produce() {

public static <T> SuspendableStream<T> iterate(T seed, UnaryOperator<T> f) {
return new SuspendableStream<>(new RootProducer<T>() {
Option<T> current = Option.none();
Option<T> current = null;
@Override
public Option<T> produce() {
return current.exists() ? current.map(f) : Option.some(seed);
current = null == current ? Option.some(seed) : current.map(f);
return current;
}
});
}

public static <T> SuspendableStream<T> iterate$(T seed, SuspendableUnaryOperator<T> f) {
return new SuspendableStream<>(new RootProducer<T>() {
Option<T> current = Option.none();
Option<T> current = null;
@Override
public Option<T> produce() {
return current.exists() ? current.map$(f) : Option.some(seed);
current = null == current ? Option.some(seed) : current.map$(f);
return current;
}
});
}
Expand Down

0 comments on commit 8f95c15

Please sign in to comment.