TAsyncManager

Manages one or more asynchronous transport resources (e.g. sockets in the case of TAsyncSocketManager) and allows work items to be submitted for them.

Implementations will typically run one or more background threads for executing the work, which is one of the reasons for a TAsyncManager to be used. Each work item is run in its own fiber and is expected to yield() away while waiting for time-consuming operations.

The second important purpose of TAsyncManager is to serialize access to the transport resources – without taking care of that, e.g. issuing multiple RPC calls over the same connection in rapid succession would likely lead to more than one request being written at the same time, causing only garbage to arrive at the remote end.

All methods are thread-safe.

Members

Functions

delay
void delay(Duration duration, void delegate() work)

Submits a delegate to be executed after a certain amount of time has passed.

execute
void execute(TAsyncTransport transport, void delegate() work, TCancellation cancellation)

Submits a work item to be executed asynchronously.

stop
bool stop(Duration waitFinishTimeout)

Shuts down all background threads or other facilities that might have been started in order to execute work items. This function is typically called during program shutdown.

Meta