Table of Contents

Interface IMainThreadQueueData

Namespace
FishMMO.Server.Core
Assembly
FishMMO.Server.dll

Runtime data container interface for a thread-safe main-thread action queue. Systems use this to marshal network operations (Broadcast, Kick, Disconnect) from async worker threads back to the main Unity thread.

public interface IMainThreadQueueData : IRuntimeDataContainer, IServerComponent

Methods

Drain()

Drains all queued actions, executing them on the calling thread. Must be called from the main Unity thread (e.g., in OnLateUpdate). Copies all queued actions under lock, then invokes them outside the lock to minimize lock hold time and avoid re-entrancy issues.

void Drain()

Drain(int)

Drains up to maxActions queued actions, executing them on the calling thread. Must be called from the main Unity thread (e.g., in OnLateUpdate).

int Drain(int maxActions)

Parameters

maxActions int

Maximum number of actions to execute in this call. Values <= 0 execute none.

Returns

int

Number of actions executed.

TryEnqueue(Action)

Thread-safe attempt to enqueue an action to the main Unity thread. Called from async worker threads.

bool TryEnqueue(Action action)

Parameters

action Action

The action to execute on the main thread.

Returns

bool

true if the action was enqueued; false if the queue is at capacity.