Skip to content

API reference / @jsprismarine/prismarine / world/ChunkScheduler

world/ChunkScheduler ​

Classes ​

Interfaces ​

ChunkRecipient ​

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:24

What the scheduler needs of a player: a queue, and a way to deliver one chunk.

Properties ​

sender ​

readonly sender: SchedulableSender

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:25

Methods ​

admits()? ​

optional admits(): boolean

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:43

Whether the recipient takes another chunk this tick, for a client that paces its own; a recipient that answers false is passed over as though its queue were empty.

Returns ​

boolean

deliver() ​

deliver(x, z): Promise<void>

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:31

Resolves once the chunk is on its way; rejects if it could not be produced.

Parameters ​
x ​

number

z ​

number

Returns ​

Promise<void>

flush() ​

flush(): Promise<void>

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:34

Dispatches whatever deliver produced but has not sent yet.

Returns ​

Promise<void>

isConnected() ​

isConnected(): boolean

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:37

Dropped from the rotation when this goes false.

Returns ​

boolean

paceTick()? ​

optional paceTick(): void

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:46

Moves the recipient's own pace on by a tick, once each scheduler tick, joined or not.

Returns ​

void

tryDeliverLoaded()? ​

optional tryDeliverLoaded(x, z): CachedChunkDelivery

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:28

Queues an already-loaded chunk synchronously, or reports that generation is still needed.

Parameters ​
x ​

number

z ​

number

Returns ​

CachedChunkDelivery


SchedulableSender ​

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:7

A queue the scheduler can drain: one player's outstanding chunks.

Methods ​

enqueue()? ​

optional enqueue(x, z): void

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:11

Restores a coordinate when a loaded-chunk delivery cannot fit this connection's byte cap.

Parameters ​
x ​

number

z ​

number

Returns ​

void

isEmpty() ​

isEmpty(): boolean

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:8

Returns ​

boolean

next() ​

next(): { x: number; z: number; } | null

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:9

Returns ​

{ x: number; z: number; } | null

Type Aliases ​

CachedChunkDelivery ​

CachedChunkDelivery = { kind: "queued"; queuedBytes: number; } | { inline?: boolean; kind: "not-loaded"; } | { kind: "backpressure"; }

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:20

Whether a recipient could queue a loaded chunk without waiting for generation capacity.

inline on a chunk that is not loaded says its world's generator builds it on this thread with no worker pool, so the delivery waits for the inline depth rather than the worker depth.


ChunkFailureHandler ​

ChunkFailureHandler = (error, coord?) => void

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:75

Told about a chunk that could not be produced or sent. coord is absent when the failure was a flush, which covers a whole batch rather than one coordinate.

Parameters ​

error ​

unknown

coord? ​
x ​

number

z ​

number

Returns ​

void

Variables ​

DEFAULT_BUDGET_MS ​

const DEFAULT_BUDGET_MS: 5 = 5

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:50

How long a tick may spend starting chunk deliveries, out of the 50 ms a tick has.


DEFAULT_DEPTH ​

const DEFAULT_DEPTH: number

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:60

How many chunk requests the server may have in flight.

The generator has its own admission queue, sized to its worker count. Keeping a second set of requests here lets it know upcoming player targets early enough to prioritize their status tasks. A host without a worker still keeps two requests in flight; its generator serializes the work itself.


DEFAULT_INLINE_DEPTH ​

const DEFAULT_INLINE_DEPTH: 64 = CHUNK_ADMISSION_BUDGET_PER_TICK

Defined in: packages/prismarine/src/world/ChunkScheduler.ts:69

How many deliveries of chunks a generator builds inline may be in flight.

No worker pool waits behind them, so the worker depth does not apply. Each one waits for the input step after its chunk is ready, and one step admits at most this many, so starting more per tick would only lengthen the wait.

References ​

chunkScheduler ​

Renames and re-exports ChunkScheduler