Table of Contents

Interface IAsyncWorkerData

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

Runtime data container interface for a centralized async work queue. Provides bounded, backpressure-aware enqueueing of async work items, executed concurrently under a configurable concurrency limit.

Systems use this instead of fire-and-forget _ = SomeAsync(...) to bound how much work is in flight at once and to get ordering guarantees for entity-keyed work.

public interface IAsyncWorkerData : IRuntimeDataContainer, IServerComponent

Properties

CompletedCount

Total number of work items processed since startup.

long CompletedCount { get; }

Property Value

long

PendingCount

Current number of items accepted but not yet started. Useful for monitoring and diagnostics.

int PendingCount { get; }

Property Value

int

Methods

Enqueue(Func<Task>, long, string)

Enqueue an async work item with an entity key for ordered processing. Work items sharing the same entityKey are guaranteed to execute in FIFO order, one at a time; items with different keys proceed independently. Returns true if the item was accepted, false if the queue is full (backpressure).

bool Enqueue(Func<Task> work, long entityKey, string callerName = null)

Parameters

work Func<Task>

The async work to execute.

entityKey long

Entity identifier for ordering (e.g., characterID), or 0 for none.

callerName string

Optional caller identifier for diagnostics.

Returns

bool

True if enqueued successfully.

Remarks

An entityKey of 0 means "no ordering requirement" and is treated exactly like the unkeyed overload. It is not an entity whose id happens to be zero, and callers that pass a default id are not asking to be serialized with each other.

Enqueue(Func<Task>, string)

Enqueue an async work item for processing. Returns true if the item was accepted, false if the queue is full (backpressure).

bool Enqueue(Func<Task> work, string callerName = null)

Parameters

work Func<Task>

The async work to execute.

callerName string

Optional caller identifier for diagnostics.

Returns

bool

True if enqueued successfully.