RE: [boost] boost.thread : Can one create a thread with anobjectmember function?

I assume I need to include some bind includes to get this to compile (I'm getting "error: `bind' undeclared in namespace `boost'". I see several includes in /usr/include/boost/bind. Which should I include? None are obvious to me, like 'bind.hpp' would be. Thanks, Tim -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Peter Dimov Sent: Monday, November 22, 2004 5:57 PM To: boost@lists.boost.org Subject: Re: [boost] boost.thread : Can one create a thread with anobjectmember function? Tim Laplaca wrote:
boost::thread_group thrds;
objclass * objthread;
objthread = new objclass;
thrds.create_thread( (objthread->p) );
Do this instead: boost::shared_ptr<objclass> objthread( new objclass ); thrds.create_thread( boost::bind( &objclass::dowork, objthread ) ); Even better, drop the objclass entirely and do this: void dowork( int tid, string valtwo ) { // do work } thrds.create_thread( boost::bind( dowork, my_thread_id, my_valtwo ) ); _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Tim Laplaca wrote:
I assume I need to include some bind includes to get this to compile (I'm getting "error: `bind' undeclared in namespace `boost'".
I see several includes in /usr/include/boost/bind. Which should I include? None are obvious to me, like 'bind.hpp' would be.
#include <boost/bind.hpp> :-)
participants (2)
-
Peter Dimov
-
Tim Laplaca