Interface IMainThreadQueueData
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
maxActionsintMaximum 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
actionActionThe action to execute on the main thread.
Returns
- bool
trueif the action was enqueued;falseif the queue is at capacity.