Skip to content

EmscriptenAsyncify

Defined in: packages/runtime/src/wasm/types.ts:222

Emscripten’s Asyncify runtime — enables WASM suspend/resume for async JS ops.

The host-side TTY bridge uses handleSleep to pause WASM when no input is available and resumes it via wakeUp(byte) when a byte arrives.

currData: unknown

Defined in: packages/runtime/src/wasm/types.ts:236

Non-null when the program is suspended (unwound). Check this instead of state because maybeStopUnwind() resets state to Normal after _main returns during unwind.


state: AsyncifyState

Defined in: packages/runtime/src/wasm/types.ts:245

Asyncify state machine. See AsyncifyState for values.

Used in get_char to detect when to return null (Unwinding) to break the TTY read loop. Prefer currData over state for “is suspended?” checks because maybeStopUnwind() resets state to 0 after _main returns.

handleSleep(callback): number

Defined in: packages/runtime/src/wasm/types.ts:230

Suspend WASM execution until wakeUp is called with a return value. Use inside TTY ops (get_char, poll) to bridge async JS → sync C.

(wakeUp) => void

number


whenDone(): Promise<number>

Defined in: packages/runtime/src/wasm/types.ts:224

Returns a promise that resolves when the program finishes after async cycles.

Promise<number>