mirror of
https://github.com/boostorg/asio.git
synced 2026-02-25 14:32:08 +00:00
Document ordering of handlers in strands. Fix error in streambuf snippet.
[SVN r59104]
This commit is contained in:
@@ -96,7 +96,7 @@ namespace asio {
|
||||
* boost::asio::streambuf b;
|
||||
*
|
||||
* // reserve 512 bytes in output sequence
|
||||
* boost::asio::streambuf::const_buffers_type bufs = b.prepare(512);
|
||||
* boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512);
|
||||
*
|
||||
* size_t n = sock.receive(bufs);
|
||||
*
|
||||
|
||||
@@ -30,6 +30,46 @@ namespace asio {
|
||||
* handlers with the guarantee that none of those handlers will execute
|
||||
* concurrently.
|
||||
*
|
||||
* @par Order of handler invocation
|
||||
* Given:
|
||||
*
|
||||
* @li a strand object @c s
|
||||
*
|
||||
* @li an object @c a meeting completion handler requirements
|
||||
*
|
||||
* @li an object @c a1 which is an arbitrary copy of @c a made by the
|
||||
* implementation
|
||||
*
|
||||
* @li an object @c b meeting completion handler requirements
|
||||
*
|
||||
* @li an object @c b1 which is an arbitrary copy of @c b made by the
|
||||
* implementation
|
||||
*
|
||||
* if any of the following conditions are true:
|
||||
*
|
||||
* @li @c s.post(a) happens-before @c s.post(b)
|
||||
*
|
||||
* @li @c s.post(a) happens-before @c s.dispatch(b), where the latter is
|
||||
* performed outside the strand
|
||||
*
|
||||
* @li @c s.dispatch(a) happens-before @c s.post(b), where the former is
|
||||
* performed outside the strand
|
||||
*
|
||||
* @li @c s.dispatch(a) happens-before @c s.dispatch(b), where both are
|
||||
* performed outside the strand
|
||||
*
|
||||
* then @c asio_handler_invoke(a1, &a1) happens-before
|
||||
* @c asio_handler_invoke(b1, &b1).
|
||||
*
|
||||
* Note that in the following case:
|
||||
* @code async_op_1(..., s.wrap(a));
|
||||
* async_op_2(..., s.wrap(b)); @endcode
|
||||
* the completion of the first async operation will perform @c s.dispatch(a),
|
||||
* and the second will perform @c s.dispatch(b), but the order in which those
|
||||
* are performed is unspecified. That is, you cannot state whether one
|
||||
* happens-before the other. Therefore none of the above conditions are met and
|
||||
* no ordering guarantee is made.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Safe.
|
||||
|
||||
Reference in New Issue
Block a user