voxolith

WorkerResponse

Any message a worker sends the pool: ready once, then one ok or error per request, correlated by id.

type WorkerResponse = 
  | {
  generators: string[];
  kind: "ready";
}
  | {
  cached?: boolean;
  entity?: Entity;
  id: number;
  key?: string;
  kind: "ok";
  packed?: PackedEntity;
}
  | {
  id: number;
  kind: "error";
  message: string;
}
  | {
  kind: "closed";
};

Defined in: engine/src/worker/protocol.ts:44

Union Members

Type Literal

{
  generators: string[];
  kind: "ready";
}

Sent once when the worker has registered its generators and can serve.


Type Literal

{
  cached?: boolean;
  entity?: Entity;
  id: number;
  key?: string;
  kind: "ok";
  packed?: PackedEntity;
}

cached?

optional cached?: boolean;

Loaded from the model cache rather than generated.

entity?

optional entity?: Entity;

The entity, as generated (an older worker's form; packed is posted instead now).

id

id: number;

key?

optional key?: string;

What produced the model: the worker's script URL, generator id and version, seed, parameters and context. The model cache's key; the pool hands it out as GeneratorPool.modelKey.

kind

kind: "ok";

packed?

optional packed?: PackedEntity;

The entity packed into one buffer (PackedEntity), transferred: a sparse model's bricks as one array rather than one buffer each, which postMessage moves far faster.


Type Literal

{
  id: number;
  kind: "error";
  message: string;
}

Type Literal

{
  kind: "closed";
}

The answer to a close: every cache write has finished, the worker may be terminated.

On this page