Skip to content

Commit ed1b22a

Browse files
committed
Starting next iteration
1 parent f3d5bc8 commit ed1b22a

File tree

12 files changed

+49
-38
lines changed

12 files changed

+49
-38
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.tascalate</groupId>
88
<artifactId>net.tascalate.concurrent</artifactId>
9-
<version>0.9.2</version>
9+
<version>0.9.3-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Tascalate Concurrent</name>

src/main/java/net/tascalate/concurrent/AbstractCompletableTask.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected void cancelOrigins(boolean mayInterruptIfRunning) {
8989
@Override
9090
public boolean cancel(boolean mayInterruptIfRunning) {
9191
if (task.cancel(mayInterruptIfRunning)) {
92-
onError(new CancellationException());
92+
failure(new CancellationException());
9393
cancelOrigins(mayInterruptIfRunning);
9494
return true;
9595
} else {
@@ -130,11 +130,11 @@ public boolean isCompletedExceptionally() {
130130
return callbackRegistry.isFailure();
131131
}
132132

133-
boolean onSuccess(T result) {
133+
boolean success(T result) {
134134
return callbackRegistry.success(result);
135135
}
136136

137-
boolean onError(Throwable ex) {
137+
boolean failure(Throwable ex) {
138138
return callbackRegistry.failure(ex);
139139
}
140140

@@ -152,13 +152,13 @@ class StageTransition extends FutureTask<T>
152152
@Override
153153
protected void set(T v) {
154154
super.set(v);
155-
onSuccess(v);
155+
success(v);
156156
};
157157

158158
@Override
159159
protected void setException(Throwable t) {
160160
super.setException(t);
161-
onError(t);
161+
failure(t);
162162
};
163163
}
164164

@@ -465,9 +465,9 @@ private <R, U> Promise<U> doApplyToEitherAsync(CompletionStage<? extends R> firs
465465
// of Future-defined methods are functional.
466466
BiConsumer<R, Throwable> action = (result, failure) -> {
467467
if (failure == null) {
468-
nextStage.onSuccess(result);
468+
nextStage.success(result);
469469
} else {
470-
nextStage.onError(forwardException(failure));
470+
nextStage.failure(forwardException(failure));
471471
}
472472
};
473473
// only the first result is accepted by completion stage,

src/main/java/net/tascalate/concurrent/ConfigurableDependentPromise.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import java.util.function.Predicate;
3737
import java.util.function.Supplier;
3838

39-
import net.tascalate.concurrent.core.Delegator;
39+
import net.tascalate.concurrent.core.Decorator;
4040
import net.tascalate.concurrent.decorators.AbstractPromiseDecorator;
4141

4242
/**
@@ -75,7 +75,7 @@
7575
* @param <T>
7676
* a type of the successfully resolved promise value
7777
*/
78-
public class ConfigurableDependentPromise<T> implements DependentPromise<T>, Delegator<T> {
78+
public class ConfigurableDependentPromise<T> implements DependentPromise<T>, Decorator<T> {
7979
protected final Promise<T> delegate;
8080
protected final CompletionStage<?>[] cancellableOrigins;
8181
protected final Set<PromiseOrigin> defaultEnlistOptions;
@@ -880,10 +880,10 @@ public String toString() {
880880
}
881881

882882
private static <T> CompletionStage<T> alphaOf(Promise<T> promise) {
883-
if (promise instanceof Delegator) {
883+
if (promise instanceof Decorator) {
884884
@SuppressWarnings("unchecked")
885-
Delegator<T> delegator = (Delegator<T>)promise;
886-
return delegator.α();
885+
Decorator<T> decorator = (Decorator<T>)promise;
886+
return decorator.α();
887887
} else {
888888
return promise;
889889
}

src/main/java/net/tascalate/concurrent/Promise.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ default Promise<T> delay(Duration duration, boolean delayOnError) {
128128
CompletableFuture<Try<? super T>> delayed = new CompletableFuture<>();
129129
whenComplete(Timeouts.configureDelay(this, delayed, duration, delayOnError));
130130
return this.dependent()
131-
.handle(Try.liftResult(), false)
131+
.handle(Try.lift(), false)
132132
// Use *Async to execute on default "this" executor
133133
.thenCombineAsync(delayed, selectFirst(), PromiseOrigin.ALL)
134134
.thenCompose(Try::asPromise, true)
@@ -151,7 +151,7 @@ default Promise<T> orTimeout(Duration duration, boolean cancelOnTimeout) {
151151
Promise<Try<T>> onTimeout = Timeouts.delayed(null, duration);
152152
DependentPromise<T> result =
153153
this.dependent()
154-
.handle(Try.liftResult(), false)
154+
.handle(Try.lift(), false)
155155
// Use *Async to execute on default "this" executor
156156
.applyToEitherAsync(onTimeout, v -> Try.doneOrTimeout(v, duration), PromiseOrigin.ALL)
157157
.thenCompose(Try::asPromise, true);
@@ -176,7 +176,7 @@ default Promise<T> onTimeout(T value, Duration duration, boolean cancelOnTimeout
176176
Promise<Try<T>> onTimeout = Timeouts.delayed(Try.success(value), duration);
177177
DependentPromise<T> result =
178178
this.dependent()
179-
.handle(Try.liftResult(), false)
179+
.handle(Try.lift(), false)
180180
// Use *Async to execute on default "this" executor
181181
.applyToEitherAsync(onTimeout, Function.identity(), PromiseOrigin.ALL)
182182
.thenCompose(Try::asPromise, true);
@@ -203,7 +203,7 @@ default Promise<T> onTimeout(Supplier<? extends T> supplier, Duration duration,
203203

204204
DependentPromise<T> result =
205205
this.dependent()
206-
.handle(Try.liftResult(), false)
206+
.handle(Try.lift(), false)
207207
.thenApply(SharedFunctions::supply, true)
208208
// Use *Async to execute on default "this" executor
209209
.applyToEitherAsync(onTimeout, Supplier::get, PromiseOrigin.ALL)

src/main/java/net/tascalate/concurrent/Promises.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,19 +1010,19 @@ public static <K, T> Promise<Map<K, T>> atLeast(int minResultsCount, int maxErro
10101010
public static Promise<Void> retry(Runnable codeBlock, Executor executor,
10111011
RetryPolicy<? super Void> retryPolicy) {
10121012

1013-
return retry(RetryRunnable.of(codeBlock), executor, retryPolicy);
1013+
return retry(RetryRunnable.from(codeBlock), executor, retryPolicy);
10141014
}
10151015

10161016
public static Promise<Void> retry(RetryRunnable codeBlock, Executor executor,
10171017
RetryPolicy<? super Void> retryPolicy) {
10181018

1019-
return retry(RetryCallable.of(codeBlock), executor, retryPolicy.acceptNullResult());
1019+
return retry(RetryCallable.from(codeBlock), executor, retryPolicy.acceptNullResult());
10201020
}
10211021

10221022
public static <T> Promise<T> retry(Callable<T> codeBlock, Executor executor,
10231023
RetryPolicy<? super T> retryPolicy) {
10241024

1025-
return retry(RetryCallable.of(codeBlock), executor, retryPolicy);
1025+
return retry(RetryCallable.from(codeBlock), executor, retryPolicy);
10261026
}
10271027

10281028
public static <T extends C, C> Promise<T> retry(RetryCallable<T, C> codeBlock, Executor executor,
@@ -1037,7 +1037,7 @@ public static <T extends C, C> Promise<T> retry(RetryCallable<T, C> codeBlock, E
10371037
public static <T> Promise<T> retryOptional(Callable<Optional<T>> codeBlock, Executor executor,
10381038
RetryPolicy<? super T> retryPolicy) {
10391039

1040-
return retryOptional(RetryCallable.of(codeBlock), executor, retryPolicy);
1040+
return retryOptional(RetryCallable.from(codeBlock), executor, retryPolicy);
10411041
}
10421042

10431043
public static <T extends C, C> Promise<T> retryOptional(RetryCallable<Optional<T>, C> codeBlock, Executor executor,
@@ -1050,7 +1050,7 @@ public static <T extends C, C> Promise<T> retryOptional(RetryCallable<Optional<T
10501050
public static <T> Promise<T> retryFuture(Callable<? extends CompletionStage<T>> invoker,
10511051
RetryPolicy<? super T> retryPolicy) {
10521052

1053-
return retryFuture(RetryCallable.of(invoker), retryPolicy);
1053+
return retryFuture(RetryCallable.from(invoker), retryPolicy);
10541054
}
10551055

10561056
public static <T extends C, C> Promise<T> retryFuture(RetryCallable<? extends CompletionStage<T>, C> futureFactory,

src/main/java/net/tascalate/concurrent/RetryCallable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
public interface RetryCallable<V, T> {
2222
V call(RetryContext<T> ctx) throws Exception;
2323

24-
public static <V, T> RetryCallable<V, T> of(Callable<? extends V> callable) {
24+
public static <V, T> RetryCallable<V, T> from(Callable<? extends V> callable) {
2525
return ctx -> callable.call();
2626
}
2727

28-
public static RetryCallable<Void, Void> of(RetryRunnable runnable) {
28+
public static RetryCallable<Void, Void> from(RetryRunnable runnable) {
2929
return ctx -> {
3030
runnable.run(ctx);
3131
return null;
3232
};
3333
}
3434

35-
public static RetryCallable<Void, Void> of(Runnable runnable) {
36-
return RetryCallable.of(RetryRunnable.of(runnable));
35+
public static RetryCallable<Void, Void> from(Runnable runnable) {
36+
return RetryCallable.from(RetryRunnable.from(runnable));
3737
}
3838
}

src/main/java/net/tascalate/concurrent/RetryRunnable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public interface RetryRunnable {
2020
void run(RetryContext<Void> ctx);
2121

22-
public static RetryRunnable of(Runnable runnable) {
22+
public static RetryRunnable from(Runnable runnable) {
2323
return ctx -> runnable.run();
2424
}
2525
}

src/main/java/net/tascalate/concurrent/Try.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static <R> Try<R> failure(Throwable error) {
9292
return new Failure<R>(error);
9393
}
9494

95-
static <R> BiFunction<R, Throwable, Try<R>> liftResult() {
95+
static <R> BiFunction<R, Throwable, Try<R>> lift() {
9696
return (result, error) -> null == error ? Try.success(result) : Try.failure(error);
9797
}
9898

src/main/java/net/tascalate/concurrent/core/Delegator.java renamed to src/main/java/net/tascalate/concurrent/core/Decorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
import java.util.concurrent.CompletionStage;
1919

20-
public interface Delegator<T> {
20+
public interface Decorator<T> {
2121
CompletionStage<T> α();
2222
}

src/main/java/net/tascalate/concurrent/decorators/AbstractPromiseLikeDecorator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
import java.util.function.Function;
2424

2525
import net.tascalate.concurrent.Promise;
26-
import net.tascalate.concurrent.core.Delegator;
26+
import net.tascalate.concurrent.core.Decorator;
2727

2828
public abstract class AbstractPromiseLikeDecorator<T, D extends CompletionStage<T>>
2929
extends AbstractCompletionStageDecorator<T, D>
30-
implements CompletionStage<T>, Delegator<T> {
30+
implements CompletionStage<T>, Decorator<T> {
3131

3232
protected AbstractPromiseLikeDecorator(D delegate) {
3333
super(delegate);
@@ -276,25 +276,25 @@ public <U> Promise<U> handleAsync(BiFunction<? super T, Throwable, ? extends U>
276276
@Override
277277
public CompletionStage<T> α() {
278278
CompletionStage<T> p = delegate;
279-
if (p instanceof Delegator) {
280-
return delegator(p).α();
279+
if (p instanceof Decorator) {
280+
return decorator(p).α();
281281
} else {
282282
// Default path -- unroll
283283
while (p instanceof AbstractCompletionStageDecorator) {
284284
@SuppressWarnings("unchecked")
285285
AbstractCompletionStageDecorator<T, ? extends CompletionStage<T>> ap =
286286
(AbstractCompletionStageDecorator<T, ? extends CompletionStage<T>>)p;
287287
p = ap.delegate;
288-
if (p instanceof Delegator) {
289-
return delegator(p).α();
288+
if (p instanceof Decorator) {
289+
return decorator(p).α();
290290
}
291291
}
292292
return p;
293293
}
294294
}
295295

296296
@SuppressWarnings("unchecked")
297-
private static <T> Delegator<T> delegator(CompletionStage<T> delegate) {
298-
return (Delegator<T>)delegate;
297+
private static <T> Decorator<T> decorator(CompletionStage<T> delegate) {
298+
return (Decorator<T>)delegate;
299299
}
300300
}

0 commit comments

Comments
 (0)