
Hi All
I'm making use of a threadpool implementation from sourceforge, which I know
is not
properly part of Boost, but I'm hoping someone has some experience which can
help
me.
I'm trying to use one of the functions from pool_adaptors.hpp, which I've
reproduced below.
I think this contains an error in the first template as the parameter passed
as a Pool is used
as a pointer to Pool, and I'm guessing there should four functions in here,
not three, as the
set seems incomplete. On either count I might be missing something.
Stripped down my code says approximately this...
#include "threadpool.hpp"
#include "boost/threadpool/pool_adaptors.hpp"
using namespace boost::threadpool;
void task( int );
vector<int> v;
v += 1,2,3,4,5,6,7,8,9;
pool my_pool;
for_each( v.begin( ), v.end( ), bind( schedule, my_pool, _1 ) );
...and of course the problem is that 'schedule' is both templated and
overloaded, so the
compiler complains it can't find/resolve 'schedule'. The usual solution is
to express the
exact type of 'schedule' required, but it's huge, and uses types internal
the the threadpool
library. Is there a better solution?
Thanks
- Rob.
namespace boost { namespace threadpool
{
// TODO convenience scheduling function
/*! Schedules a Runnable for asynchronous execution. A Runnable is an
arbitrary class with a run()
* member function. This a convenience shorthand for
pool->schedule(bind(&Runnable::run, task_object)).
* \param
* \param obj The Runnable object. The member function run() will be
exectued and should not throw execeptions.
* \return true, if the task could be scheduled and false otherwise.
*/
template