Like this: http://liveworkspace.org/code/48075598fce1ae0fef0badc6ea95a1db
tp.schedule(boost::bind(&Model::runTask, &myTask, _1));
2011/9/25 Jack Bryan <dtustudy68@hotmail.com>_______________________________________________Hi,
I am trying to do multithreading byboost::bind
. But, I got error:src/model.cpp:225: instantiated from hereHere is my code:
/boost_1_45_0v/include/boost/bind/mem_fn.hpp:333: error: pointer to member typevoid (Model::)(taskDataSPType&)
incompatible with object typetaskDataSPT1ype
make: * [model.o] Error 1
In another header file, I have :void Model::runTask(taskDataSPType& myTask)
{}
taskDataSPType myTask;
fifo_pool tp(thread_num);
for (int i = 0 ; i < totalTaskNum ; +i)
{
taskQueue.wait_and_pop(myTask, i);
myTask.taskID = i ;
// run the typical iterations
tp.schedule(boost::bind(&Model::runTask, &myTask));
}
tp.wait();
typedef struct taskDataSPT1ype taskDataSPType;
struct taskDataSPT1ype
{
int taskID;
int startNode;
int endNode;
};
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users