Skip to content

API reference / @jsprismarine/chunkgen / HostedGenerationPool

Class: HostedGenerationPool ​

Defined in: HostedGenerationPool.ts:87

Runs generation tasks in a child process, with the in-process pool as its fallback.

Implements ​

Constructors ​

Constructor ​

new HostedGenerationPool(options): HostedGenerationPool

Defined in: HostedGenerationPool.ts:119

Parameters ​

options ​

HostedGenerationPoolOptions

Returns ​

HostedGenerationPool

Properties ​

options ​

readonly options: HostedGenerationPoolOptions

Defined in: HostedGenerationPool.ts:119

Accessors ​

hostPid ​

Get Signature ​

get hostPid(): number | undefined

Defined in: HostedGenerationPool.ts:122

The host's process id, or undefined before it starts and while running in process.

Returns ​

number | undefined


inFlight ​

Get Signature ​

get inFlight(): number

Defined in: HostedGenerationPool.ts:140

How many tasks the workers are holding right now.

Returns ​

number

How many tasks the workers are holding right now.

Implementation of ​

GenerationTransport.inFlight


priorityLowered ​

Get Signature ​

get priorityLowered(): boolean

Defined in: HostedGenerationPool.ts:127

Whether lowering the host's priority succeeded.

Returns ​

boolean


queued ​

Get Signature ​

get queued(): number

Defined in: HostedGenerationPool.ts:144

How many tasks are waiting for a worker.

Returns ​

number

How many tasks are waiting for a worker.

Implementation of ​

GenerationTransport.queued


usingFallback ​

Get Signature ​

get usingFallback(): boolean

Defined in: HostedGenerationPool.ts:132

Whether tasks run in this process because no host could be kept alive.

Returns ​

boolean


workers ​

Get Signature ​

get workers(): number

Defined in: HostedGenerationPool.ts:136

How many workers are up.

Returns ​

number

How many workers are up.

Implementation of ​

GenerationTransport.workers

Methods ​

cancel() ​

cancel(wanted): number

Defined in: HostedGenerationPool.ts:173

Asks the host to drop the waiting tasks a predicate rejects.

Parameters ​

wanted ​

(task) => boolean

Returns ​

number

Implementation of ​

GenerationTransport.cancel


destroy() ​

destroy(): Promise<void>

Defined in: HostedGenerationPool.ts:224

Stops the host, refusing everything outstanding, and waits for it to exit.

Returns ​

Promise<void>

Implementation of ​

GenerationTransport.destroy


promote() ​

promote(wanted, to): number

Defined in: HostedGenerationPool.ts:190

Moves waiting tasks up into a band, here and at the host.

Parameters ​

wanted ​

(task) => boolean

to ​

"immediate" | "soon" | "idle"

Returns ​

number

Implementation of ​

GenerationTransport.promote


resetStats() ​

resetStats(): void

Defined in: HostedGenerationPool.ts:211

Forgets the recorded stats.

Returns ​

void

Implementation of ​

GenerationTransport.resetStats


run() ​

run(task, priority?): Promise<GenerationResult>

Defined in: HostedGenerationPool.ts:149

Runs one task in the host, or in process after a fallback.

Parameters ​

task ​

GenerationTask

priority? ​

"immediate" | "soon" | "idle" = 'immediate'

Returns ​

Promise<GenerationResult>

Implementation of ​

GenerationTransport.run


setBackgroundLimit() ​

setBackgroundLimit(limit): void

Defined in: HostedGenerationPool.ts:217

Limits how many background tasks the host's workers run at once.

Parameters ​

limit ​

number | undefined

Returns ​

void

Implementation of ​

GenerationTransport.setBackgroundLimit


statsSnapshot() ​

statsSnapshot(): GenerationStatsSnapshot

Defined in: HostedGenerationPool.ts:206

What this side recorded: round-trip turnaround and the worker times the host reported.

Returns ​

GenerationStatsSnapshot

Implementation of ​

GenerationTransport.statsSnapshot


unavailable() ​

static unavailable(options): string | undefined

Defined in: HostedGenerationPool.ts:107

Why a host cannot be started here, or undefined when one can.

A Bun-compiled executable starts the host by running itself again, so it needs no file, only an entry that answers the host role. Node's single executable cannot yet, and the host entry has to be on disk for anything else.

Parameters ​

options ​

GenerationPoolOptions

Returns ​

string | undefined