diff --git a/README.md b/README.md
index 6b6f4d2..761ee51 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,8 @@ repositories {
}
dependencies {
- compile 'dev.tommyjs:futur-api:2.1.2'
- compile 'dev.tommyjs:futur-reactor:2.1.2'
- compile 'dev.tommyjs:futur-reactive-streams:2.1.2'
+ compile 'dev.tommyjs:futur-api:2.1.3'
+ compile 'dev.tommyjs:futur-reactor:2.1.3'
}
```
### Gradle DSL
@@ -25,9 +24,8 @@ repositories {
}
dependencies {
- implementation("dev.tommyjs:futur-api:2.1.2")
- implementation("dev.tommyjs:futur-reactor:2.1.2")
- implementation("dev.tommyjs:futur-reactive-streams:2.1.2")
+ implementation("dev.tommyjs:futur-api:2.1.3")
+ implementation("dev.tommyjs:futur-reactor:2.1.3")
}
```
### Maven
@@ -43,17 +41,12 @@ dependencies {
dev.tommyjs
futur-api
- 2.1.2
+ 2.1.3
dev.tommyjs
futur-reactor
- 2.1.2
-
-
- dev.tommyjs
- futur-reactive-streams
- 2.1.1
+ 2.1.3
```
@@ -164,10 +157,5 @@ This can also be applied to key-value scenarios in the same way, where you can p
### Future wrappers
External libaries provide asynchronous ways to interact with their output in all shapes and sizes. Futur4J currently has wrappers for the following libraries/frameworks:
-- Reactive Streams (via futur-reactive-streams)
- Reactor Core (via futur-reactor)
- Java CompletableFuture (via `Promises.wrap` in futur-api)
-
-Coming Soon:
-- Lettuce (redis futures)
-- Netty futures (maybe?)
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..9d9df61
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,30 @@
+plugins {
+ id 'com.github.johnrengelman.shadow' version '8.1.1'
+ id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
+}
+
+nexusPublishing {
+ repositories {
+ tommyjs {
+ nexusUrl = uri("https://repo.tommyjs.dev/repository/maven-releases")
+ }
+ }
+}
+
+subprojects {
+ group = "dev.tommyjs"
+ version = "2.1.3"
+
+ apply plugin: 'java'
+ apply plugin: 'com.github.johnrengelman.shadow'
+
+ tasks {
+ build {
+ dependsOn(tasks.shadowJar)
+ }
+ }
+
+ repositories {
+ mavenCentral()
+ }
+}
\ No newline at end of file
diff --git a/futur-api/build.gradle b/futur-api/build.gradle
new file mode 100644
index 0000000..6ba9400
--- /dev/null
+++ b/futur-api/build.gradle
@@ -0,0 +1,4 @@
+dependencies {
+ implementation("org.jetbrains:annotations:24.1.0")
+ implementation("org.slf4j:slf4j-api:2.0.12")
+}
\ No newline at end of file
diff --git a/futur-api/build.gradle.kts b/futur-api/build.gradle.kts
deleted file mode 100644
index 85db17e..0000000
--- a/futur-api/build.gradle.kts
+++ /dev/null
@@ -1,34 +0,0 @@
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-
-plugins {
- id("java")
- id("com.github.johnrengelman.shadow") version "7.1.2"
-}
-
-group = "dev.tommyjs"
-version = "2.1.2"
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation("org.jetbrains:annotations:24.1.0")
- implementation("org.slf4j:slf4j-api:2.0.9")
- testImplementation(platform("org.junit:junit-bom:5.9.1"))
- testImplementation("org.junit.jupiter:junit-jupiter")
-}
-
-tasks {
- build {
- dependsOn(shadowJar)
- }
-
- withType {
- exclude("META-INF/**")
- }
-}
-
-tasks.test {
- useJUnitPlatform()
-}
\ No newline at end of file
diff --git a/futur-api/src/main/java/dev/tommyjs/futur/promise/AbstractPromise.java b/futur-api/src/main/java/dev/tommyjs/futur/promise/AbstractPromise.java
index f1dfaa9..0c68588 100644
--- a/futur-api/src/main/java/dev/tommyjs/futur/promise/AbstractPromise.java
+++ b/futur-api/src/main/java/dev/tommyjs/futur/promise/AbstractPromise.java
@@ -37,14 +37,13 @@ public abstract class AbstractPromise implements Promise {
@Override
public T join(long timeoutMillis) throws TimeoutException {
- PromiseCompletion completion = this.completion.get();
- if (completion != null) return joinCompletion(completion);
-
+ PromiseCompletion completion;
long start = System.currentTimeMillis();
long remainingTimeout = timeoutMillis;
synchronized (this.completion) {
- while (completion == null && remainingTimeout > 0){
+ completion = this.completion.get();
+ while (completion == null && remainingTimeout > 0) {
try {
this.completion.wait(remainingTimeout);
} catch (InterruptedException e) {
diff --git a/futur-reactive-streams/.gitignore b/futur-reactive-streams/.gitignore
deleted file mode 100644
index b63da45..0000000
--- a/futur-reactive-streams/.gitignore
+++ /dev/null
@@ -1,42 +0,0 @@
-.gradle
-build/
-!gradle/wrapper/gradle-wrapper.jar
-!**/src/main/**/build/
-!**/src/test/**/build/
-
-### IntelliJ IDEA ###
-.idea/modules.xml
-.idea/jarRepositories.xml
-.idea/compiler.xml
-.idea/libraries/
-*.iws
-*.iml
-*.ipr
-out/
-!**/src/main/**/out/
-!**/src/test/**/out/
-
-### Eclipse ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-bin/
-!**/src/main/**/bin/
-!**/src/test/**/bin/
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-
-### VS Code ###
-.vscode/
-
-### Mac OS ###
-.DS_Store
\ No newline at end of file
diff --git a/futur-reactive-streams/build.gradle.kts b/futur-reactive-streams/build.gradle.kts
deleted file mode 100644
index 4f63a34..0000000
--- a/futur-reactive-streams/build.gradle.kts
+++ /dev/null
@@ -1,35 +0,0 @@
-import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
-
-plugins {
- id("java")
- id("com.github.johnrengelman.shadow") version "7.1.2"
-}
-
-group = "dev.tommyjs"
-version = "2.1.2"
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation("org.jetbrains:annotations:24.1.0")
- compileOnly(project(mapOf("path" to ":futur-api")))
- compileOnly("org.reactivestreams:reactive-streams:1.0.4")
- testImplementation(platform("org.junit:junit-bom:5.9.1"))
- testImplementation("org.junit.jupiter:junit-jupiter")
-}
-
-tasks {
- build {
- dependsOn(shadowJar)
- }
-
- withType {
- exclude("META-INF/**")
- }
-}
-
-tasks.test {
- useJUnitPlatform()
-}
\ No newline at end of file
diff --git a/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/ReactiveTransformer.java b/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/ReactiveTransformer.java
deleted file mode 100644
index bb608c5..0000000
--- a/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/ReactiveTransformer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package dev.tommyjs.futur.reactivestreams;
-
-import dev.tommyjs.futur.promise.Promise;
-import dev.tommyjs.futur.promise.PromiseFactory;
-import org.jetbrains.annotations.NotNull;
-import org.reactivestreams.Publisher;
-
-public class ReactiveTransformer {
-
- public static @NotNull Promise wrapPublisher(@NotNull Publisher publisher, PromiseFactory factory) {
- SingleAccumulatorSubscriber subscriber = SingleAccumulatorSubscriber.create(factory);
- publisher.subscribe(subscriber);
- return subscriber.getPromise();
- }
-
-}
diff --git a/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/SingleAccumulatorSubscriber.java b/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/SingleAccumulatorSubscriber.java
deleted file mode 100644
index e45e55c..0000000
--- a/futur-reactive-streams/src/main/java/dev/tommyjs/futur/reactivestreams/SingleAccumulatorSubscriber.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package dev.tommyjs.futur.reactivestreams;
-
-import dev.tommyjs.futur.promise.Promise;
-import dev.tommyjs.futur.promise.PromiseFactory;
-import dev.tommyjs.futur.impl.StaticPromiseFactory;
-import org.reactivestreams.Subscriber;
-import org.reactivestreams.Subscription;
-
-public class SingleAccumulatorSubscriber implements Subscriber {
-
- private final Promise promise;
-
- public SingleAccumulatorSubscriber(Promise promise) {
- this.promise = promise;
- }
-
- @Override
- public void onSubscribe(Subscription s) {
- s.request(1);
- }
-
- @Override
- public void onNext(T t) {
- promise.complete(t);
- }
-
- @Override
- public void onError(Throwable t) {
- promise.completeExceptionally(t);
- }
-
- @Override
- public void onComplete() {
- // ignore
- }
-
- public Promise getPromise() {
- return promise;
- }
-
- public static SingleAccumulatorSubscriber create(Promise promise) {
- return new SingleAccumulatorSubscriber<>(promise);
- }
-
- public static SingleAccumulatorSubscriber create(PromiseFactory factory) {
- return create(factory.unresolved());
- }
-
- public static SingleAccumulatorSubscriber create() {
- return create(StaticPromiseFactory.INSTANCE);
- }
-
-}
diff --git a/futur-reactor/build.gradle b/futur-reactor/build.gradle
new file mode 100644
index 0000000..42dc278
--- /dev/null
+++ b/futur-reactor/build.gradle
@@ -0,0 +1,5 @@
+dependencies {
+ compileOnly(project(":futur-api"))
+ implementation("org.jetbrains:annotations:24.1.0")
+ implementation("io.projectreactor:reactor-core:3.6.4")
+}
\ No newline at end of file
diff --git a/futur-reactor/build.gradle.kts b/futur-reactor/build.gradle.kts
deleted file mode 100644
index 7e123e9..0000000
--- a/futur-reactor/build.gradle.kts
+++ /dev/null
@@ -1,24 +0,0 @@
-plugins {
- id("java")
- id("com.github.johnrengelman.shadow") version "7.1.2"
-}
-
-group = "dev.tommyjs"
-version = "2.1.2"
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation("org.jetbrains:annotations:24.1.0")
- compileOnly(project(mapOf("path" to ":futur-api")))
- implementation("io.projectreactor:reactor-core:3.6.0")
- implementation(project(mapOf("path" to ":futur-reactive-streams")))
- testImplementation(platform("org.junit:junit-bom:5.9.1"))
- testImplementation("org.junit.jupiter:junit-jupiter")
-}
-
-tasks.test {
- useJUnitPlatform()
-}
\ No newline at end of file
diff --git a/futur-reactor/src/main/java/dev/tommyjs/futur/reactor/ReactorTransformer.java b/futur-reactor/src/main/java/dev/tommyjs/futur/reactor/ReactorTransformer.java
index bf934b5..0683dab 100644
--- a/futur-reactor/src/main/java/dev/tommyjs/futur/reactor/ReactorTransformer.java
+++ b/futur-reactor/src/main/java/dev/tommyjs/futur/reactor/ReactorTransformer.java
@@ -3,29 +3,13 @@ package dev.tommyjs.futur.reactor;
import dev.tommyjs.futur.promise.Promise;
import dev.tommyjs.futur.promise.PromiseFactory;
import org.jetbrains.annotations.NotNull;
-import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
-
public class ReactorTransformer {
public static @NotNull Promise wrapMono(@NotNull Mono mono, PromiseFactory factory) {
Promise promise = factory.unresolved();
- mono.doOnSuccess(promise::complete).doOnError(promise::completeExceptionally).subscribe();
- return promise;
- }
-
- public static @NotNull Promise<@NotNull List> wrapFlux(@NotNull Flux flux, PromiseFactory factory) {
- Promise> promise = factory.unresolved();
- AtomicReference> out = new AtomicReference<>(new ArrayList<>());
-
- flux.doOnNext(out.get()::add).subscribe();
- flux.doOnComplete(() -> promise.complete(out.get())).subscribe();
- flux.doOnError(promise::completeExceptionally).subscribe();
-
+ mono.subscribe(promise::complete, promise::completeExceptionally);
return promise;
}
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..025feb7
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,4 @@
+rootProject.name = 'futur'
+
+include 'futur-api'
+include 'futur-reactor'
diff --git a/settings.gradle.kts b/settings.gradle.kts
deleted file mode 100644
index 6881e96..0000000
--- a/settings.gradle.kts
+++ /dev/null
@@ -1,5 +0,0 @@
-rootProject.name = "futur"
-include("futur-api")
-include("futur-standalone")
-include("futur-reactive-streams")
-include("futur-reactor")
\ No newline at end of file