|
Boost : |
From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-03-07 04:00:03
"Agarwal, Abhishek" <Abhishek.Agarwal_at_[hidden]> writes:
> I am new to boost and hence i would like to ask a few questions on multi
> threading feature of this library. I am ataching a program can some one help
> to find out why i am getting this error as given follows
>
> Master.cpp: In member function `void master::Master::createt()':
> Master.cpp:17: error: no matching function for call to
> `boost::thread::thread(<unknown type>)'
> /opt/boost/include/boost-1_33_1/boost/thread/thread.hpp:35: note: candidates
> are: boost::thread::thread(const boost::thread&)
> /opt/boost/include/boost-1_33_1/boost/thread/thread.hpp:38: note:
> boost::thread::thread(const boost::function0<void,
> std::allocator<boost::function_base> >&)
> /opt/boost/include/boost-1_33_1/boost/thread/thread.hpp:37: note:
> boost::thread::thread()
The constructor for boost::thread takes a function with no parameters, through
the boost::function0 template. Non-static member functions do not fit the bill
--- they need an object to be invoked against, the implicit 'this' parameter.
You can bind the member function with an appropriate 'this' parameter to make
it callable without parameters using boost.bind:
#include "boost/bind.hpp"
void master::Master::createt(){
thread t1(boost::bind(&Master::sleepslave,this));
}
HTH,
Anthony
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk