Skip to main content

Module shared_world

Module shared_world 

Source
Expand description

Lock-free double-buffered compact replication layout.

This module implements the “Shared World” logic which allows the Game Worker to write authoritative updates while the Render Worker reads a stable snapshot without blocking, satisfying the zero-cost synchronization requirement of M360.

Structs§

SabHeader
The header for the SharedArrayBuffer.
SabSlot
A single replicated entity state in the compact shared buffer (48 bytes). Optimized for Void Rush (2D gameplay with 3D elevation).
SharedWorld
A lock-free double buffer for compact entity replication. This points into a SharedArrayBuffer allocated by the Main Thread.

Constants§

MAX_ENTITIES
Maximum number of entities supported in the compact shared buffer. Total slots = 16,384 (8,192 per buffer).
SHARED_MEMORY_SIZE
Total size in bytes required for the compact replication layout. 32 bytes (Header) + 384 KiB (Buffer A) + 384 KiB (Buffer B) = 768 KiB + 32 bytes. Note: Rounded to 768 KiB in documentation, exact size is 786,464 bytes.