mirror of
https://github.com/tommyskeff/futur4j.git
synced 2026-01-18 07:16:45 +00:00
add cancellation and refractor PromiseFactory
This commit is contained in:
@@ -3,6 +3,8 @@ package dev.tommyjs.futur.promise;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
|
||||
public class PromiseCompletion<T> {
|
||||
|
||||
private @Nullable T result;
|
||||
@@ -36,6 +38,10 @@ public class PromiseCompletion<T> {
|
||||
return getException() != null;
|
||||
}
|
||||
|
||||
public boolean wasCanceled() {
|
||||
return getException() instanceof CancellationException;
|
||||
}
|
||||
|
||||
public @Nullable T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user