Class Anira#
The module on the page’s main thread: await Anira.create() instantiates it on a shared
memory (anira.abi is its typed C ABI, AniraBindings; anira.module the
instance) and boots the main thread’s registry. Every other thread is started by anira from C on
the same memory. See Basic Usage.
- class Anira(module, memory)#
The module on the page’s main thread: its typed C ABI (abi), the instance (module) and its shared memory. Every other thread of the page (the context’s inference Workers, the audio worklet) is started by anira from C on the same memory. One per page.
- Arguments:
module (AbiModule)
memory (Memory)
- static async create(options={})#
Instantiate the module on a shared memory (options.memory: 128 MiB growing to 2 GiB by default) and boot the main thread’s registry.
- Arguments:
options (AniraOptions)
- Returns:
Promise<Anira>
- Anira.abi#
type: readonly AniraBindings
- Anira.module#
type: readonly AbiModule
- Anira.memory#
type: readonly Memory
- Anira.version#
type: readonly string
The library’s release identity (anira_version_string), e.g. “3.0.0-alpha.3”.
- setLogSink(onRecord=consoleLogSink)#
Route the log of the main thread to
onRecord(the console when omitted;nullremoves the sink): the records logged here and thosedrainLogdelivers here, the real-time records of every thread among them (anira_em_set_log_hook). The web twin of anira::ContextConfig::log_sink, set on the module rather than a context config (the sink is the scope’s registry, one per realm, called with a record object instead of the C function and itsuser_data). Records a Worker logs itself reach that scope’s registry, which writes them to the console unless the Worker’s module sets scopeRegistry().logSink. While a sink is set it replaces the module’s platform sink (the console by level), so each record reaches the console once;nullrestores the platform sink.- Arguments:
onRecord (null | (record: LogRecord) => void)
- drainLog()#
Deliver the queued real-time records (anira_drain_log) to the sinks; the web has no drain thread. Returns the number delivered.
- Returns:
number
- startLogPump(intervalMs=20)#
Drain the log on a main-thread interval; returns the function that stops it.
- Arguments:
intervalMs (number)
- Returns:
() => void