Engine#

Lifecycle#

Engine#

constructor(options?: { runId?: string | null; tierId?: string | null; });

One libds engine, created by ds_engine_new from a ds_engine_config_t.

class Engine extends EventTarget. A realm that has not opened libds throws Error. runId or tierId of another type, or a string holding U+0000 or a lone surrogate, throws TypeError. A call that libds refuses throws a DsError. An engine collected without close is freed.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)

close#

close(): void;

Releases the engine through ds_engine_free, with its callbacks and a running recording.

A second close does nothing. After close, a call that reaches libds through the engine, its Clock or its Cache throws a DsError with DS_ERR_STATE, and each of its Facts is dead. A close inside one of the engine’s callbacks or its recording sink throws a DsError with DS_ERR_STATE, and changes nothing.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)

using#

[Symbol.dispose](): void;

Calls close when the scope of a using declaration ends.

A platform with no Symbol.dispose has no such method.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

clone#

clone(): Engine;

Returns an independent copy of the engine, made by ds_engine_clone.

The copy has its own Clock and Cache, and no listener or callback of the source’s. A Fact of the source is refused by the copy with DS_ERR_FACT_INVALID, and factById finds the copy’s fact.

const copy = engine.clone();
copy.pump();
copy.close();

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)

runId#

get runId(): string | null;

The run id, read by ds_engine_get_run_id.

It is null for an id not given or given as "".

(Source: bindings/js/types/bind.d.ts, bindings/js/src/ds.c)

tierId#

get tierId(): string | null;

The tier id, read by ds_engine_get_tier_id.

It is null for an id not given or given as "".

(Source: bindings/js/types/bind.d.ts, bindings/js/src/ds.c)

Running#

loadDsc#

loadDsc(bytes: Uint8Array): void;

Loads a compiled artefact through ds_engine_load_dsc.

A value that is not a Uint8Array throws TypeError. The next read of schemas, rules or lineSpans reads the engine again, whether the load succeeded or not.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)

pump#

pump(): void;

Runs one pump, through ds_engine_pump.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

Halt#

halted#

get halted(): number | null;

The fault that halted the engine, read by ds_engine_halted, as the number of its ds_engine_fault_t.

It is null until the halt latch is set, and 0 for an engine a failed load spent.

Note

A halted engine can read 0, which is falsy. Compare halted with null.

(Source: bindings/js/types/bind.d.ts, bindings/js/src/ds.c)

Measurement#

memory#

memory(): MemoryReport;

Measures the engine through ds_engine_mem.

It walks the engine’s structures at each call.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

MemoryReport#

export type MemoryReport = { wmFactCount: number; wmFactBytes: number; wmIndexBytes: number; alphaNodeCount: number; alphaMatchCount: number; alphaIndexBytes: number; betaNodeCount: number; betaTokenCount: number; betaTokenBytes: number; betaIndexBytes: number; internCount: number; internStringBytes: number; internIndexBytes: number; poolReservedBytes: number; totalBytes: number; };

A plain object of ds_engine_mem_t, each field in camelCase, as a Number.

(Source: bindings/js/types/types.d.ts, bindings/js/src/ds.c)

Provenance#

platformSignature#

get platformSignature(): PlatformSignature;

The engine’s platform signature, read by ds_engine_get_platform_signature.

Each read makes a new snapshot.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

PlatformSignature#

export type PlatformSignature = { osFamily: string; cpuArch: string; libc: string; compiler: string; libdsVersion: string; backends: string[]; };

A plain object of ds_platform_signature_t, each field in camelCase.

(Source: bindings/js/types/types.d.ts, bindings/js/src/ds.c)

sessionHeader#

get sessionHeader(): SessionHeader;

The engine’s session header, read by ds_engine_get_session_header.

Each read makes a new snapshot.

(Source: bindings/js/types/bind.d.ts, bindings/js/lib/bind.js)

SessionHeader#

export type SessionHeader = { dsVersion: string; sessionId: string; tierId: string; dscHash: Uint8Array | null; };

A plain object of ds_session_header_t, each field in camelCase.

dscHash is a copy of the loaded artefact’s hash, and null before a load.

(Source: bindings/js/types/types.d.ts, bindings/js/lib/bind.js, bindings/js/src/ds.c)