How do I run tasks in Fibers once the Fiber.schedule methods are gone?
Alan Bateman
Alan.Bateman at oracle.com
Sat Jul 20 14:17:05 UTC 2019
On 20/07/2019 14:54, Arkadiusz Gasiński wrote:
> Hi,
>
> As the subject line says, how shall I schedule a task to run in Fiber now
> that the static Fiber.schedule methods are no longer available?
All fibers are scheduled in a fiber scope. The javadoc has some examples
that might help and I'm sure we'll expand those as the API progresses,
e.g. get started with:
try (var scope = FiberScope.open()) {
Fiber<String> fiber = scope.schedule(() -> "foo");
}
If you really want to schedule a fiber that outlives its parent then you
can use FiberScope.background().schedule(...). The static schedule
methods were just convenience methods for doing that but they didn't
help with structured usage.
-Alan
More information about the loom-dev
mailing list