A type of double buffer meant to handle resolution of interlude.reactive.Tasks, but can work on any Void functions.

Consumes the entire buffer, swapping the front and back buffers until both are empty

Call resolve in your event loop to resolve Tasks

Constructor

new()

Variables

@:value([])read onlybackBuffer:Array<() ‑> Void> = []

@:value([])read onlyfrontBuffer:Array<() ‑> Void> = []

Methods

queue(fn:() ‑> Void):Int

Pushes a callback function into the buffer

Returns:

The new length of the buffer fn was added to

queueMany(fns:Array<() ‑> Void>):Array<() ‑> Void>

Pushes an Array of callback functions into the buffer

Returns:

A reference to the updated buffer

resolve():Void

Calls every callback in the front buffer, then swaps buffers. Loops until both buffers are consumed, so some care must be taken to avoid infinite loops

resolveOnce():Void

Calls every callback in the front buffer, then swaps buffers. This version only consumes the front buffer, so subsequent calls must be made to continue processing