diff --git a/.classpath b/.classpath index 6190f20..1e326ef 100644 --- a/.classpath +++ b/.classpath @@ -2,6 +2,7 @@ + @@ -17,7 +18,7 @@ - + @@ -28,5 +29,11 @@ + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 8b5c4dc..c447060 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=12 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=12 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -11,6 +11,6 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=12 diff --git a/README.md b/README.md index 6fe64b1..52c85b4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate/net.tascalate.concurrent.svg)](https://search.maven.org/artifact/net.tascalate/net.tascalate.concurrent/0.9.6/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-concurrent.svg)](https://github.com/vsilaev/tascalate-concurrent/releases/tag/0.9.6) [![license](https://img.shields.io/github/license/vsilaev/tascalate-concurrent.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) +[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate/net.tascalate.concurrent.svg)](https://search.maven.org/artifact/net.tascalate/net.tascalate.concurrent/0.9.7/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-concurrent.svg)](https://github.com/vsilaev/tascalate-concurrent/releases/tag/0.9.7) [![license](https://img.shields.io/github/license/vsilaev/tascalate-concurrent.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) # tascalate-concurrent The library provides an implementation of the [CompletionStage](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html) interface and related classes these are designed to support long-running blocking tasks (typically, I/O bound). This functionality augments the sole Java 8 built-in implementation, [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), that is primarily supports computational tasks. Also, the library helps with numerous asynchronous programing challenges like handling timeouts, retry/poll functionality, orchestrating results of multiple concurrent computations and similar. @@ -12,7 +12,7 @@ New name: net.tascalate net.tascalate.concurrent - 0.9.6 + 0.9.7 ``` Old Name @@ -38,7 +38,7 @@ To use a library you have to add a single Maven dependency net.tascalate net.tascalate.concurrent - 0.9.6 + 0.9.7 ``` # What is inside? diff --git a/pom.xml b/pom.xml index 531ca76..6d54bf6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.tascalate net.tascalate.concurrent - 0.9.6 + 0.9.7 jar Tascalate Concurrent diff --git a/src/main/java/net/tascalate/concurrent/PromiseOperations.java b/src/main/java/net/tascalate/concurrent/PromiseOperations.java index cc6f405..4fea0c5 100644 --- a/src/main/java/net/tascalate/concurrent/PromiseOperations.java +++ b/src/main/java/net/tascalate/concurrent/PromiseOperations.java @@ -94,9 +94,9 @@ public static > Function peek(Consumer return p -> unwrap(Promises.tryComposeEx(p.dependent(PromiseOrigin.ALL), fn)); } - public static Function>, Promise> + public static Function>, Promise> partitionedItems(int batchSize, - Function> spawner, + Function> spawner, Collector downstream) { return p -> p.dependent() @@ -105,9 +105,9 @@ public static > Function peek(Consumer .unwrap(); } - public static Function>, Promise> + public static Function>, Promise> partitionedItems(int batchSize, - Function> spawner, + Function> spawner, Collector downstream, Executor downstreamExecutor) { @@ -117,9 +117,9 @@ public static > Function peek(Consumer .unwrap(); } - public static Function>, Promise> + public static Function>, Promise> partitionedStream(int batchSize, - Function> spawner, + Function> spawner, Collector downstream) { return p -> p.dependent() @@ -128,9 +128,9 @@ public static > Function peek(Consumer .unwrap(); } - public static Function>, Promise> + public static Function>, Promise> partitionedStream(int batchSize, - Function> spawner, + Function> spawner, Collector downstream, Executor downstreamExecutor) { diff --git a/src/main/java/net/tascalate/concurrent/Promises.java b/src/main/java/net/tascalate/concurrent/Promises.java index ba64034..7d46459 100644 --- a/src/main/java/net/tascalate/concurrent/Promises.java +++ b/src/main/java/net/tascalate/concurrent/Promises.java @@ -253,41 +253,41 @@ public static Promise tryComposeEx(Promise p }); } - public static Promise partitioned(Iterable values, - int batchSize, - Function> spawner, - Collector downstream) { + public static Promise partitioned(Iterable values, + int batchSize, + Function> spawner, + Collector downstream) { return partitioned1(values.iterator(), null, batchSize, spawner, downstream); } - public static Promise partitioned(Iterable values, - int batchSize, - Function> spawner, - Collector downstream, - Executor downstreamExecutor) { + public static Promise partitioned(Iterable values, + int batchSize, + Function> spawner, + Collector downstream, + Executor downstreamExecutor) { return partitioned2(values.iterator(), null, batchSize, spawner, downstream, downstreamExecutor); } - public static Promise partitioned(Stream values, - int batchSize, - Function> spawner, - Collector downstream) { + public static Promise partitioned(Stream values, + int batchSize, + Function> spawner, + Collector downstream) { return partitioned1(values.iterator(), values, batchSize, spawner, downstream); } - public static Promise partitioned(Stream values, - int batchSize, - Function> spawner, - Collector downstream, - Executor downstreamExecutor) { + public static Promise partitioned(Stream values, + int batchSize, + Function> spawner, + Collector downstream, + Executor downstreamExecutor) { return partitioned2(values.iterator(), values, batchSize, spawner, downstream, downstreamExecutor); } - private static Promise partitioned1(Iterator values, - Object source, - int batchSize, - Function> spawner, - Collector downstream) { + private static Promise partitioned1(Iterator values, + Object source, + int batchSize, + Function> spawner, + Collector downstream) { return parallelStep1(values, batchSize, spawner, downstream) .dependent() @@ -296,12 +296,12 @@ private static Promise partitioned1(Iterator values, .unwrap(); } - private static Promise partitioned2(Iterator values, - Object source, - int batchSize, - Function> spawner, - Collector downstream, - Executor downstreamExecutor) { + private static Promise partitioned2(Iterator values, + Object source, + int batchSize, + Function> spawner, + Collector downstream, + Executor downstreamExecutor) { return parallelStep2(values, batchSize, spawner, downstream, downstreamExecutor) .dependent() @@ -310,13 +310,13 @@ private static Promise partitioned2(Iterator values, .unwrap(); } - private static Promise> parallelStep1( - Iterator values, int batchSize, - Function> spawner, + private static Promise> parallelStep1( + Iterator values, int batchSize, + Function> spawner, Collector downstream) { return loop(new IndexedStep<>(), step -> step.initial() || values.hasNext(), step -> { - List valuesBatch = drainBatch(values, batchSize); + List valuesBatch = drainBatch(values, batchSize); if (valuesBatch.isEmpty()) { // Over return Promises.success(step.initial() ? step.next(downstream.supplier().get()) : step); @@ -336,14 +336,14 @@ private static Promise> parallelStep1( }); } - private static Promise> parallelStep2( - Iterator values, int batchSize, - Function> spawner, + private static Promise> parallelStep2( + Iterator values, int batchSize, + Function> spawner, Collector downstream, Executor downstreamExecutor) { return loop(new IndexedStep<>(), step -> step.initial() || values.hasNext(), step -> { - List valuesBatch = drainBatch(values, batchSize); + List valuesBatch = drainBatch(values, batchSize); if (valuesBatch.isEmpty()) { // Over return step.initial() ?