Can i do something like below ? Is it possible or is there any workaround?
..
PostWorkToThread( boost::bind(func_x, arg1) );
PostWorkToThread( boost::bind(func_y, arg1, arg2) );
PostWorkToThread( boost::bind(func_z, arg1, arg2, arg3) );
..
void PostWorkToThread( boost::bind xxx )
{
PostWork( boost::bind(xxx) ); or
PostWork( xxx );
}
Thank you, I appreciate your suggestion.
Since the type of the function object generated by
boost::bind(andstd::bind) is not specified, you should makePostWorkToThreada template:Alternatively, you could use
boost::function(orstd::function) to erase the type of the function object:Note that in this case
boost::function(andstd::function) may have to dynamically allocate memory to store the function object. However, you will likely have to do it anyway to enqueue the function for execution, so this is probably not a problem.