TAsyncManager.execute

Submits a work item to be executed asynchronously.

Access to asnyc transports is serialized – if two work items associated with the same transport are submitted, the second delegate will not be invoked until the first has returned, even it the latter context-switches away (because it is waiting for I/O) and the async manager is idle otherwise.

Optionally, a TCancellation instance can be specified. If present, triggering it will be considered a request to cancel the work item, if it is still waiting for the associated transport to become available. Delegates which are already being processed (i.e. waiting for I/O) are not affected because this would bring the connection into an undefined state (as probably half-written request or a half-read response would be left behind).

interface TAsyncManager
void
execute

Parameters

transport TAsyncTransport

The TAsyncTransport the work delegate will operate on. Must be associated with this TAsyncManager instance.

work void delegate
()

The operations to execute on the given transport. Must never throw, errors should be handled in another way. nothrow semantics are difficult to enforce in combination with fibres though, so currently exceptions are just swallowed by TAsyncManager implementations.

cancellation TCancellation

If set, can be used to request cancellatinon of this work item if it is still waiting to be executed.

Note: The work item will likely be executed in a different thread, so make sure the code it relies on is thread-safe. An exception are the async transports themselves, to which access is serialized as noted above.

Meta