allow joining without a timeout

This commit is contained in:
WhatCats
2024-04-11 23:57:44 +02:00
parent ed98a7e914
commit dc5171ad31
3 changed files with 49 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import dev.tommyjs.futur.function.ExceptionalConsumer;
import dev.tommyjs.futur.function.ExceptionalFunction;
import dev.tommyjs.futur.function.ExceptionalRunnable;
import dev.tommyjs.futur.function.ExceptionalSupplier;
import org.jetbrains.annotations.Blocking;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -123,7 +124,20 @@ public interface Promise<T> {
void completeExceptionally(@NotNull Throwable result);
T join(long timeout) throws TimeoutException;
@Blocking
T await();
@Blocking
T await(long timeout) throws TimeoutException;
/**
* @deprecated Use await instead.
*/
@Blocking
@Deprecated
default T join(long timeout) throws TimeoutException {
return await(timeout);
};
@Nullable PromiseCompletion<T> getCompletion();