asio C++ library

PrevUpHomeNext

Child Agents

The asynchronous operations within an agent may themselves be implemented in terms of child agents.[3] As far as the parent agent is concerned, it is waiting for the completion of a single asynchronous operation. The asynchronous operations that constitute the child agent run in sequence, and when the final completion handler runs the parent agent is resumed.

As with individual asynchronous operations, the asynchronous operations built on child agents must release their temporary resources prior to calling the completion handler. We may also think of these child agents as resources that end their lifetimes before the completion handler is invoked.

When an asynchronous operation creates a child agent, it may propagate[4] the associated characteristics of the parent agent to the child agent. These associated characteristics may then be recursively propagated through further layers of asynchronous operations and child agents. This stacking of asynchronous operations replicates another property of synchronous operations.

Property of synchronous operations

Equivalent property of asynchronous operations

Compositions of synchronous operations may be refactored to use child functions that run on the same thread (i.e. are simply called) without altering functionality.

Asynchronous agents may be refactored to use asynchronous operations and child agents that share the associated characteristics of the parent agent, without altering functionality.

Finally, some asynchronous operations may be implemented in terms of multiple child agents that run concurrently. In this case, the asynchronous operation may choose to selectively propagate the associated characteristics of the parent agent.



[3] In Asio these asynchronous operations are referred to as composed operations.

[4] Typically, by specialising the associator trait and forwarding to the outer completion handler.


PrevUpHomeNext