FiberA coroutine: a block that can suspend itself with Fiber.yield: -- or the ^> value sugar -- and be resumed by its caller, exchanging values both ways. Cooperative and in-task; for concurrent tasks whose I/O overlaps, use Task / Async instead.
var f = Fiber.new:{ ^> 1; 2 }; #( f.resume f.resume f.status ) "* -> #(1 2 done)
The currently running fiber, or nil outside any fiber.
A fresh, unstarted fiber wrapping the zero-parameter block (status 'created'). Nothing runs until the first resume.
As yield: with nil.
Suspend the running fiber, delivering the value as the pending resume's result; the value a later resume: passes becomes this expression's value. ^> value is the yield sugar.
var f = Fiber.new:{ var got = ^> 1; got * 10 }; f.resume; "* -> 1 f.resume:5 "* -> 50
True while the fiber can still be resumed (not yet done or failed).
True once the fiber's block returned normally.
The error value if the fiber failed; nil otherwise.
True once the fiber's block raised an uncaught error (the error re-raised at the resume that observed it; error keeps the value).
The fiber's final return value; nil unless it completed normally.
Run the fiber until its next yield or completion; answers the yielded (or final) value. If the fiber's block raised, the error re-raises here. Resuming a finished fiber -- or one live in another task -- raises a FiberError.
As resume, delivering the value as the result of the yield expression the fiber is suspended at.
One of 'created', 'suspended', 'running', 'done', 'failed'.
(Fiber.new:{ }).status "* -> created