Supersede

A token that ends many runs at once without interrupting them: give it to each run you might replace, Machine.run(machine, sink, { supersede: token }), then end it, and each run still going leaves the Frame loop and succeeds with Superseded, neither settled nor failed. It costs about a sixth of interrupting each run's fiber, which counts when one change replaces thousands of runs.

import * as Supersede from "@wardic/core/Supersede"

const token = Supersede.make()
// each run a later change replaces:
Machine.run(machine, sink, { supersede: token }) // succeeds with Supersede.Superseded once ended
// the change:
Supersede.end(token)

Interfaces

Run

A run a token can end: the Frame loop's entry for it.

Properties

removed
removed: boolean;

Whether it has left the Frame loop.

settled
readonly settled: Deferred<
  | Frame<unknown>
| typeof Superseded>;

Its fiber's outcome: its settled frame, or Superseded.


Supersede

A token for the runs a caller may replace together: each run given it joins it, and end ends them all.

Extends

  • Pipeable
  • Inspectable

Properties

~@wardic/core/Supersede
readonly "~@wardic/core/Supersede": "~@wardic/core/Supersede";
runs
readonly runs: readonly Run[];

The runs given this token and not yet ended by it. The Frame loop adds to it.

Type Aliases

Superseded

type Superseded = typeof Superseded;

The type of Superseded.

Variables

Superseded

const Superseded: unique symbol;

What a superseded run succeeds with, where a settled one succeeds with its settled Frame.

Functions

end()

function end(token): void;

End every run given token that's still on the Frame loop, at once: each leaves the loop (a run ended during a tick gets no Frame from it), and its fiber resumes with Superseded. A run that already settled, failed or was interrupted is left as it ended. The token is empty after, and a run given it later joins it again. Calling end again is harmless.

Parameters

token

Supersede

Returns

void


isSupersede()

function isSupersede(u): u is Supersede;

Whether u is a token.

Parameters

u

unknown

Returns

u is Supersede


isSuperseded()

function isSuperseded(u): u is typeof Superseded;

Whether a run's outcome is Superseded.

Parameters

u

unknown

Returns

u is typeof Superseded


make()

function make(): Supersede;

A fresh token, with no runs.

Returns

Supersede