Logo Mibo

IntentQueue Type

The intent queue of an adaptive program: the single place to post unit -> unit work during Update. Intents are work items deferred to a moment the runtime owns, exposed as moment-named entry points: IntentQueue.post (later in this step), IntentQueue.postNextFrame (top of the next step), and IntentQueue.postTask / IntentQueue.postAsync (background work whose completion returns via post). The adaptive counterpart of Cmd — closures capture the handler, so no message type is needed.

All three lanes are multi-producer, single-consumer queues: a ConcurrentQueue for producers, drained by the single consumer (the runner) on the owner thread. The post drain runs until empty — work posted during the drain runs in the same drain, in post order, mirroring MVU's DispatchMode.Immediate semantics; work that posts more work is the user's responsibility, exactly as message cycles are in MVU. The first post drain is the startup drain: it runs right after Init returns, before the first frame is forced, so work Init posted through its context lands before the first frame. The pre-step lane holds subscription events and drains once per Step at the boundary, before Update; the next-frame lane also drains once per Step at the boundary, never per sub-step. Allocation: one queue node per posted work item — acceptable on the cold path, zero on steps with no posted work.

Constructors

Constructor Description

IntentQueue()

Full Usage: IntentQueue()

Returns: IntentQueue
Returns: IntentQueue

Instance members

Instance member Description

this.post work

Full Usage: this.post work

Parameters:
    work : unit -> unit - The work to run at the post drain.

Defers work to the next post drain: it runs on the owner thread after the next Update (after each sub-step's Update under fixed-step), in post order, drained until empty, before the frame is forced. From Init, the next post drain is the startup drain: it runs right after Init returns, before the first frame is forced. Cross-system reactions, foreign-thread posts, and async completions go here. Safe to call from any thread; the work itself must only run owner-thread legal writes (plain Set calls). The adaptive counterpart of Cmd.ofMsg.

work : unit -> unit

The work to run at the post drain.

this.postAsync (work, ofSuccess, ofError)

Full Usage: this.postAsync (work, ofSuccess, ofError)

Parameters:
    work : Async<'T> - The async workflow to start; must not touch the graph.
    ofSuccess : 'T -> unit - Receives the result on the owner thread at a later post drain.
    ofError : exn -> unit - Receives the exception on the owner thread at a later post drain.

Type parameters: 'T

Defers an F# async workflow to this queue: the starter runs on the owner thread at the next post drain and starts the workflow on the thread pool — the workflow body runs off the owner thread — and the completion (ofSuccess or ofError) is posted to the same lane and runs on the owner thread at a later post drain, where root writes are legal. The runtime handles the thread handoff for you — you never post or pump directly. The adaptive counterpart of Cmd.ofAsync.

work : Async<'T>

The async workflow to start; must not touch the graph.

ofSuccess : 'T -> unit

Receives the result on the owner thread at a later post drain.

ofError : exn -> unit

Receives the exception on the owner thread at a later post drain.

this.postNextFrame work

Full Usage: this.postNextFrame work

Parameters:
    work : unit -> unit - The work to run at the next step's boundary.

Defers work to the top of the NEXT AdaptiveHeadless.Step: it runs on the owner thread at the frame boundary, after cross-thread posts are applied (Posting.pump) and before the time root is written. The adaptive counterpart of Cmd.deferNextFrame — the lane exists for work that must not run in the step that posted it. Safe to call from any thread.

work : unit -> unit

The work to run at the next step's boundary.

this.postTask (work, ofSuccess, ofError)

Full Usage: this.postTask (work, ofSuccess, ofError)

Parameters:
    work : unit -> Task<'T> - The background work to start; must not touch the graph.
    ofSuccess : 'T -> unit - Receives the result on the owner thread at a later post drain.
    ofError : exn -> unit - Receives the exception on the owner thread at a later post drain.

Type parameters: 'T

Defers a background task to this queue: the starter runs on the owner thread at the next post drain and hands the work to the thread pool — work (the task creation call) and the task itself run off the owner thread — and the completion (ofSuccess or ofError) is posted to the same lane and runs on the owner thread at a later post drain, where root writes are legal. The runtime handles the thread handoff for you — you never post or pump directly. The adaptive counterpart of Cmd.ofTask.

work : unit -> Task<'T>

The background work to start; must not touch the graph.

ofSuccess : 'T -> unit

Receives the result on the owner thread at a later post drain.

ofError : exn -> unit

Receives the exception on the owner thread at a later post drain.

Type something to start searching.