add cancellation and refractor PromiseFactory

This commit is contained in:
WhatCats
2024-04-04 17:36:35 +02:00
parent e6eee4e849
commit 5bbcfdc9b3
24 changed files with 670 additions and 445 deletions

View File

@@ -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;
}