asio C++ library

PrevUpHomeNext

io_service::wrap

(Deprecated: Use wrap.) Create a new handler that automatically dispatches the wrapped handler on the io_service.

template<
    typename Handler>
unspecified wrap(
    Handler handler);

This function is used to create a new handler function object that, when invoked, will automatically pass the wrapped handler to the io_service object's dispatch function.

Parameters

handler

The handler to be wrapped. The io_service will make a copy of the handler object as required. The function signature of the handler must be:

void handler(A1 a1, ... An an);

Return Value

A function object that, when invoked, passes the wrapped handler to the io_service object's dispatch function. Given a function object with the signature:

R f(A1 a1, ... An an);

If this function object is passed to the wrap function like so:

io_service.wrap(f);

then the return value is a function object with the signature

void g(A1 a1, ... An an);

that, when invoked, executes code equivalent to:

io_service.dispatch(boost::bind(f, a1, ... an));

PrevUpHomeNext