Fiber Helper
A helper class, one per fiber. It's referenced referenced through a pojo from a field of the fiber, so that the FiberDescriptor can be easily switched from mutable to immutable or shared, without cloning the state.
Parameters
A zero-argument Kotlin Function that produces the name for this fiber. It's computed lazily at most once, using the Kotlin lazy mechanism. Note that after it's computed and cached in the name property, the nameSupplier function is no longer referenced by the lazy mechanism. The function should avoid execution of Avail code as that could easily lead to deadlocks.
Constructors
Properties
The AvailDebuggerModel that has captured this fiber, if any.
A function which checks whether the given fiber should run, based on what has been set up by the debugger. This must be non-null whenever the fiber is captured by a debugger.
A raw pojo holding a StringBuilder in which logging should take place for this fiber. This is a very fast way of doing logging, since it doesn't have to write to disk or update a user interface component, and garbage collection of a fiber which has terminated typically also collects that fiber's log.
A 64-bit unique value for this fiber, allocated from a monotonically increasing counter. Since it's only used for debugging, it's safe even if the counter eventually overflows.
The ExecutionState of the fiber, indicating whether the fiber is e.g., running, suspended or terminated.
The fiber's Flags, encoded as an AtomicInteger.
A set of raw pojos, each of which wraps an action indicating what to do with the fiber's reified CONTINUATION when the fiber next reaches a suitable safe point.
Functions
Atomically replace the given flag with the boolean, answering the boolean that previously occupied that flag.
Retrieve the given flag as a boolean.
Replace the nameSupplier. This also clears the cached name.
Atomically replace the given flag with the boolean.
The fiber has just started running, so do what must be done for the correct accounting of CPU time by the fiber.
The fiber has just stopped running, either due to completion, an interrupt, or suspension, so do what must be done for the correct accounting of CPU time by the fiber.