How do I run tasks in Fibers once the Fiber.schedule methods are gone?
Alan Bateman
Alan.Bateman at oracle.com
Sun Jul 21 13:24:24 UTC 2019
On 20/07/2019 15:56, Arkadiusz Gasiński wrote:
> Awesome, thanks!
>
> Also, given these changes to Fiber's API, what would be the
> recommended way to rewrite Mark's code
> <https://youtu.be/Csc2JRs6470?t=1598> he wrote for his loom rest demo
> he did at Devoxx last year?
>
> I assume that FiberScope.background().schedule() would be the simplest
> way to refactor his ThreadPool.execute(Runnable) method, but perhaps
> maintaining a dedicated FiberScope in the ThreadPool would be a better
> idea (though FiberScope.isClosed() method would be useful to not
> schedule new tasks if the scope has been closed)?
>
For the Jetty "replace thread pool with fibers" example then
FiberScope.background().schedule(...) should work fine. A FiberScope can
only be closed by its owner so it's not possible to close the
background/primordial scope. I don't think anyone has looked at changes
to Jetty to get it work with structured concurrency, that could be an
interesting experiment.
-Alan.
More information about the loom-dev
mailing list