Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-08-31 12:55:47

From: Christopher Kohlhoff <chris_at_[hidden]>
> --- Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> wrote:
> > win_iocp_operation is a base class that takes a pointer to a function
> > and when called(when the IO operation is completed) it executes its
> > pointer. The pointer is normally a static function to a derived class
> > that calls the apropriate handler.
> > But I dont quite follow the virtual function overhead in this case. I
> > think that asio is reinventing the wheel and with the same overhead.
> The overhead is not the virtual function call itself, but all the other
> stuff that gets generated by the compiler as soon as you add a virtual
> function to a class (e.g. vtable, RTTI etc).

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.

If you provide for context, then you might want to combine the
function pointer and context information into an object that will
keep the values together not only in the win_iocp_operation
invocation mentioned above, but in data members and other
function calls that follow. That helps the client to combine
them properly and it helps asio to keep them correctly

(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.)

Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at