Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-08-31 17:38:39


Hi Rob,

--- Rob Stewart <stewart_at_[hidden]> wrote:
> Should that interface take an extra argument (void *, for
> example) that permits the client to get back some context? The
> client may need to provide a this pointer or allocate a structure
> on the free store and get back data needed to correctly react.

The context is the pointer to the win_iocp_operation object. The way it
works is like this:

- The class to perform the asynchronous handling is derived from
win_iocp_operation, which is in turn derived from OVERLAPPED. Any
context information (e.g. the application's handler for the operation)
is stored as a data member in this class:

  OVERLAPPED
     ^
     |
  win_iocp_operation
     ^
     |
  send_operation<HANDLER>

- When an async operation is started, a new instance of the derived
class is created, and it is passed as the OVERLAPPED* argument of the
asynchronous operation (e.g. ::WSASend).

- In win_iocp_demuxer_service::run(), the call to
::GetQueuedCompletionStatus retrieves the OVERLAPPED* value, which it
then casts to win_iocp_operation and then calls the associated function
pointer.

- The class derived from win_iocp_operation invokes the application's
handler.

> (If there are no other arguments to the win_iocp_operation
> invocation, then the client needn't be bothered with creating
> such a structure, but the implementation might still want to.)

Please remember that all this stuff is right down in the bowels of
asio. A user of asio never needs to deal with it.

Cheers,
Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk