Skip to content

MTY_RunAndYield

chrisd1100 edited this page Apr 30, 2023 · 1 revision

Runs a loop while also allowing the OS's event loop to continue to run.

This function only matters when targeting the Web. If a regular while loop is used to block a thread, under the hood the Worker that is executing the WebAssembly will be blocked and can not process the JavaScript event loop. This means that the Worker can not communicate with the main thread via postMessage, and most importantly can not perform deferred cleanup via the event loop, causing memory leaks.

void MTY_RunAndYield(
    MTY_IterFunc iter,
    void *       opaque
);

Parameters

iter (MTY_IterFunc)

Function called in a loop until it returns false.

opaque (void *)

Pointer passed to each call to iter.

Platform support

Windows   macOS   Android   Linux   Web  

See also

Module: App

Clone this wiki locally