Skip to content

API reference / @jsprismarine/prismarine / world/ChunkAdmissions / ChunkAdmissions

Class: ChunkAdmissions ​

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:142

Chunk completions held for the input step, the second kind of input after packets (ADR 0009).

A chunk that has been read or generated, or one whose unload has been saved, waits here until an input step applies it, so a tick never sees the loaded set change in its middle. The step admits up to a count, rotating three turns of player-visible work to one each of background and idle work, and records each admission with its tick. A replay installs the trace with replay, and from then on each step admits exactly the recorded completions of its tick, in recorded order, whatever is ready and whatever the count would allow.

Implements ​

Constructors ​

Constructor ​

new ChunkAdmissions(tick?, budget?): ChunkAdmissions

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:177

Parameters ​

tick? ​

() => number

The tick the server is running, read for an admission made outside an input step.

budget? ​

number = CHUNK_ADMISSION_BUDGET_PER_TICK

The most completions one input step admits while no trace decides.

Returns ​

ChunkAdmissions

Accessors ​

isActive ​

Get Signature ​

get isActive(): boolean

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:182

Whether completions wait for an input step. When false, a completion is applied at once.

Returns ​

boolean

Whether completions wait for an input step. When false, a completion is applied at once.

Implementation of ​

ChunkAdmissionScheduler.isActive


pending ​

Get Signature ​

get pending(): number

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:187

How many completions wait for an input step.

Returns ​

number

Methods ​

activate() ​

activate(): void

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:192

Starts holding completions for the input step.

Returns ​

void


admit() ​

admit(tick): number

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:289

The chunk half of the input step: applies the completions this tick admits, one after another, each to its end before the next, in one call.

Without a trace, the step takes up to the budget of the completions held when it begins. Under a trace, it takes the recorded completions of tick in recorded order, and a recorded one that is not held is reported as a divergence and skipped. A skipped one is admitted at the first later step that holds it, ahead of that step's own records, and reported again.

Parameters ​

tick ​

number

The tick whose input step this is.

Returns ​

number

How many completions the step applied.


deactivate() ​

deactivate(): void

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:197

Stops holding completions and applies every held one, in lane order, one after another.

Returns ​

void


hold() ​

hold(completion): Promise<boolean>

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:235

Holds a completion for the next input step, or applies it now when no tick loop runs. A second completion for the same chunk and direction replaces the first, which rejects.

Parameters ​

completion ​

ChunkCompletion

The completion.

Returns ​

Promise<boolean>

Settles with what the completion's apply returned, once it has been applied.

Implementation of ​

ChunkAdmissionScheduler.hold


promote() ​

promote(admission, priority): boolean

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:263

Moves a held completion to a more urgent lane, such as a background chunk a player now stands in.

Parameters ​

admission ​

ChunkAdmission

priority ​

"immediate" | "soon" | "idle"

Returns ​

boolean

Whether it moved; false when nothing is held or the lane is not more urgent.

Implementation of ​

ChunkAdmissionScheduler.promote


replay() ​

replay(replay): void

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:214

Makes a captured trace decide what each input step admits from fromTick on.

Parameters ​

replay ​

ChunkAdmissionReplay

The trace, and where it starts in this run.

Returns ​

void


setRecorder() ​

setRecorder(recorder): void

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:205

Sends every admission from now on to recorder, with a digest of each entering chunk.

Parameters ​

recorder ​

ChunkAdmissionRecorder | undefined

Returns ​

void


snapshot() ​

snapshot(): ChunkAdmissionSnapshot

Defined in: packages/prismarine/src/world/ChunkAdmissions.ts:296

What the queue holds and has admitted so far.

Returns ​

ChunkAdmissionSnapshot