public final class FiberUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <V> java.util.List<V> |
get(Fiber<V>... fibers)
Blocks on the input fibers and creates a new list from the results.
|
static <V> java.util.List<V> |
get(java.util.List<Fiber<V>> fibers)
Blocks on the input fibers and creates a new list from the results.
|
static <V> java.util.List<V> |
get(long time,
java.util.concurrent.TimeUnit unit,
Fiber<V>... fibers)
Blocks on the input fibers and creates a new list from the results.
|
static <V> java.util.List<V> |
get(long timeout,
java.util.concurrent.TimeUnit unit,
java.util.List<Fiber<V>> fibers)
Blocks on the input fibers and creates a new list from the results.
|
static <V> V |
runInFiber(FiberScheduler scheduler,
SuspendableCallable<V> target)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static void |
runInFiber(FiberScheduler scheduler,
SuspendableRunnable target)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V> V |
runInFiber(SuspendableCallable<V> target)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static void |
runInFiber(SuspendableRunnable target)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V,X extends java.lang.Exception> |
runInFiberChecked(FiberScheduler scheduler,
SuspendableCallable<V> target,
java.lang.Class<X> exceptionType)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static <X extends java.lang.Exception> |
runInFiberChecked(FiberScheduler scheduler,
SuspendableRunnable target,
java.lang.Class<X> exceptionType)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V,X extends java.lang.Exception> |
runInFiberChecked(SuspendableCallable<V> target,
java.lang.Class<X> exceptionType)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static <X extends java.lang.Exception> |
runInFiberChecked(SuspendableRunnable target,
java.lang.Class<X> exceptionType)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V> V |
runInFiberRuntime(FiberScheduler scheduler,
SuspendableCallable<V> target)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static void |
runInFiberRuntime(FiberScheduler scheduler,
SuspendableRunnable target)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V> V |
runInFiberRuntime(SuspendableCallable<V> target)
Runs an action in a new fiber, awaits the fiber's termination, and returns its result.
|
static void |
runInFiberRuntime(SuspendableRunnable target)
Runs an action in a new fiber and awaits the fiber's termination.
|
static <V> java.util.concurrent.Future<V> |
toFuture(Fiber<V> fiber)
Turns a fiber into a
Future. |
public static <V> java.util.concurrent.Future<V> toFuture(Fiber<V> fiber)
Future.V - fiber - the fiberFuture representing the fiber.public static <V> V runInFiber(SuspendableCallable<V> target) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
default scheduler.V - target - the operationjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic static <V> V runInFiber(FiberScheduler scheduler, SuspendableCallable<V> target) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
V - scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic static void runInFiber(SuspendableRunnable target) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
default scheduler.
.target - the operationjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic static void runInFiber(FiberScheduler scheduler, SuspendableRunnable target) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic static <V> V runInFiberRuntime(SuspendableCallable<V> target) throws java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException.
The new fiber is scheduled by the default scheduler.V - target - the operationjava.lang.InterruptedExceptionpublic static <V> V runInFiberRuntime(FiberScheduler scheduler, SuspendableCallable<V> target) throws java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException.V - scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationjava.lang.InterruptedExceptionpublic static void runInFiberRuntime(SuspendableRunnable target) throws java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException.
The new fiber is scheduled by the default scheduler.target - the operationjava.lang.InterruptedExceptionpublic static void runInFiberRuntime(FiberScheduler scheduler, SuspendableRunnable target) throws java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException.scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationjava.lang.InterruptedExceptionpublic static <V,X extends java.lang.Exception> V runInFiberChecked(SuspendableCallable<V> target, java.lang.Class<X> exceptionType) throws X extends java.lang.Exception, java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException.
The new fiber is scheduled by the default scheduler.V - target - the operationjava.lang.InterruptedExceptionX extends java.lang.Exceptionpublic static <V,X extends java.lang.Exception> V runInFiberChecked(FiberScheduler scheduler, SuspendableCallable<V> target, java.lang.Class<X> exceptionType) throws X extends java.lang.Exception, java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException, unless it is of the given exception type, in
which case the checked exception is thrown as-is.V - scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationexceptionType - a checked exception type that will not be wrapped if thrown by the operation, but thrown as-is.java.lang.InterruptedExceptionX extends java.lang.Exceptionpublic static <X extends java.lang.Exception> void runInFiberChecked(SuspendableRunnable target, java.lang.Class<X> exceptionType) throws X extends java.lang.Exception, java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException, unless it is of the given exception type, in
which case the checked exception is thrown as-is.
The new fiber is scheduled by the default scheduler.target - the operationexceptionType - a checked exception type that will not be wrapped if thrown by the operation, but thrown as-is.java.lang.InterruptedExceptionX extends java.lang.Exceptionpublic static <X extends java.lang.Exception> void runInFiberChecked(FiberScheduler scheduler, SuspendableRunnable target, java.lang.Class<X> exceptionType) throws X extends java.lang.Exception, java.lang.InterruptedException
runInFiber this method does not throw ExecutionException, but wraps
any checked exception thrown by the operation in a RuntimeException, unless it is of the given exception type, in
which case the checked exception is thrown as-is.scheduler - the FiberScheduler to use when scheduling the fiber.target - the operationexceptionType - a checked exception type that will not be wrapped if thrown by the operation, but thrown as-is.java.lang.InterruptedExceptionX extends java.lang.Exceptionpublic static <V> java.util.List<V> get(java.util.List<Fiber<V>> fibers) throws java.lang.InterruptedException
fibers - to combinejava.lang.InterruptedExceptionpublic static <V> java.util.List<V> get(Fiber<V>... fibers) throws java.lang.InterruptedException
fibers - to combinejava.lang.InterruptedExceptionpublic static <V> java.util.List<V> get(long timeout,
java.util.concurrent.TimeUnit unit,
java.util.List<Fiber<V>> fibers)
throws java.lang.InterruptedException,
java.util.concurrent.TimeoutException
timeout - to wait for all requests to completeunit - the time is infibers - to combinejava.lang.InterruptedExceptionjava.util.concurrent.TimeoutExceptionpublic static <V> java.util.List<V> get(long time,
java.util.concurrent.TimeUnit unit,
Fiber<V>... fibers)
throws java.lang.InterruptedException,
java.util.concurrent.TimeoutException
time - to wait for all requests to completeunit - the time is infibers - to combinejava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException