API reference

MeshCacheSweepSystem Class

Extends SystemBase
Modifiers: final
Defers MeshManager.sweepUnusedMeshes to a later frame so per-entity teardown can complete safely before the mesh dedup cache is freed. Sweeping synchronously, mid-frame, can leave dangling native pointers that the next frame's renderer or input system reads.
Use MeshCacheSweepSystem.scheduleSweep to enqueue a sweep; it runs on a later MeshCacheSweepSystem.execute tick.
Registered as an early system by ToolkitFeature.earlySystemsToRegister.

Signature

class MeshCacheSweepSystem(val meshManager: MeshManager) : SystemBase

Constructors

MeshCacheSweepSystem ( meshManager )
Signature
constructor(meshManager: MeshManager)
Parameters
meshManager: MeshManager  The MeshManager whose dedup cache is swept when a request matures.

Properties

executeCount : Long
[Get]
The number of times this system's SystemBase.execute method has been called by the system manager. Incremented automatically before each execution cycle. Useful for performance monitoring.
@Volatile guarantees atomic 64-bit reads + happens-before semantics so the introspection reader (which runs on the dump caller's thread) observes a consistent value. Only SystemBase.incrementExecuteCount writes this field, so the non-atomic read-modify-write is safe.
Signature
var executeCount: Long
meshManager : MeshManager
[Get]
The MeshManager whose dedup cache is swept when a request matures.
Signature
val meshManager: MeshManager
systemManager : SystemManager
[Get][Set]
The SystemManager that this system is registered with. Provides access to other systems and the scene. Initialized during system registration.
Signature
lateinit var systemManager: SystemManager

Methods

associateSystemManager ( systemManager )
Associates this system with a SystemManager. Called during registration. Throws RuntimeException if the system is already associated — each system instance can only belong to one manager.
Signature
fun associateSystemManager(systemManager: SystemManager)
Parameters
systemManager: SystemManager  The system manager that will own and execute this system.
delete ( entity )
Called when an SystemBase.delete is removed from the scene. Override to clean up any per-entity state this system maintains, such as cached components, tracking maps, or native resource handles.
Signature
open fun delete(entity: Entity)
Parameters
entity: Entity
destroy ()
Process-shutdown safety: drop any still-pending sweeps.
Signature
open override fun destroy()
equals ( other )
Checks if this system is equal to another object. Two systems are considered equal if they are the same instance or share the same Kotlin class, regardless of configuration state.
Signature
open operator override fun equals(other: Any?): Boolean
Parameters
other: Any?  The object to compare with.
Returns
Boolean  True if the other object is the same system instance or the same system class.
execute ()
Called each frame by the SystemManager to perform this system's per-tick logic. Override to query entities with relevant components and apply updates.
Signature
open override fun execute()
getDependencies ()
Returns the execution ordering dependencies for this system. Override to declare which other systems must run before or after this one using SystemDependencies.
Signature
open fun getDependencies(): SystemDependencies?
Returns
SystemDependencies?  The dependency configuration, or null if this system has no ordering constraints.
getScene ()
Returns the Scene that this system operates within. Delegates to the associated SystemManager to retrieve the active scene instance.
Signature
fun getScene(): Scene
Returns
Scene  The scene containing the entities and rendering state for this system.
hashCode ()
Returns the hash code of this system, based on its Kotlin class identity. Consistent with the SystemBase.equals implementation — systems of the same class produce the same hash code.
Signature
open override fun hashCode(): Int
Returns
Int  The hash code derived from this system's Kotlin class.
scheduleSweep ( candidateTokens , framesToWait )
Schedules a deferred sweep of the MeshManager dedup cache for MeshCacheSweepSystem.scheduleSweep to run MeshCacheSweepSystem.scheduleSweep frames from now (default 2).
The sweep is conservative: only entries in MeshCacheSweepSystem.scheduleSweep that no live mesh-bearing entity still references are freed. No-op for an empty MeshCacheSweepSystem.scheduleSweep set. Safe to call from any thread.
Signature
fun scheduleSweep(candidateTokens: Set<String>, framesToWait: Int = 2)
Parameters
candidateTokens: Set  cache keys the caller is willing to free. Snapshotted into the pending request — the caller may safely mutate the original after this returns.
framesToWait: Int  number of MeshCacheSweepSystem.execute ticks to wait before invoking the sweep. Must be >= 0; 0 runs the sweep on the next tick. Defaults to 2.