FiberHelper

class FiberHelper(loader: AvailLoader?, textInterface: TextInterface, initialPriority: Int, nameSupplier: () -> A_String)

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

nameSupplier

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

Link copied to clipboard
constructor(loader: AvailLoader?, textInterface: TextInterface, initialPriority: Int, nameSupplier: () -> A_String)

Properties

Link copied to clipboard

The AvailDebuggerModel that has captured this fiber, if any.

Link copied to clipboard

A function which checks whether the given fiber is allowed to perform a function invocation without checking with the debuggerRunCondition. Note that (1) both regular and non-local control flow (e.g., exceptions, time slicing, backtracking) will exit from the JVM stack frame that observed this to be true and invoked a function, and (2) user-interface debugger control only happens during safe points, so it's safe to temporarily replace the debuggerRunCondition before the invocation and restore it after the JVM-level call returns.

Link copied to clipboard

A function which checks whether the fiber in the given interpreter 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.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

The ExecutionState of the fiber, indicating whether the fiber is e.g., running, suspended or terminated.

Link copied to clipboard

The fiber's Flags, encoded as an AtomicInteger.

Link copied to clipboard
val hash: Int

The random, permanent hash value of the fiber.

Link copied to clipboard

The name of this fiber. It's computed lazily from the nameSupplier Function provided during creation (or updated later). The resulting A_String must be shared, but the constructor and the updater ensure that.

Link copied to clipboard

The fiber's priority, in [0..255]. Higher priority fibers are serviced more quickly than lower priority fibers. 255 is the highest priority and 0 is the lowest.

Link copied to clipboard

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

Link copied to clipboard

Answer a Long, representing nanoseconds, which increases monotonically at the normal rate of time while the fiber is running, but stops when it is not.

Link copied to clipboard

Atomically replace the given flag with the boolean, answering the boolean that previously occupied that flag.

Link copied to clipboard

Retrieve the given flag as a boolean.

Link copied to clipboard
fun nameSupplier(nameSupplier: () -> A_String)

Replace the nameSupplier. This also clears the cached name.

Link copied to clipboard

Atomically replace the given flag with the boolean.

Link copied to clipboard

The fiber has just started running, so do what must be done for the correct accounting of CPU time by the fiber.

Link copied to clipboard

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.