I am currently working on network software. It has one main class server, which obviously represents a server instance.
A serverinstance can send requests, and the user gets a callback response.
The code looks like this:
class server
{
public:
typedef boost::function<void (int duration)> callback_func;
void send_request(endpoint& ep, callback_func cb);
};
Now let me say that, as a user, I want the callback to know about the instance that called it, I can do the following:
void mycallback(const server& sv, int duration) { ... }
server sv;
sv.send_request("localhost", boost::bind(&mycallback, boost::ref(sv), _1));
But I wonder: is there any overhead? Will calls be mycallbackslower than using a “normal” call?
Thank.
: , , typedef : typedef boost::function<void (const server& sv, int duration)> callback_func;, boost::bind , , . , boost::bind.