Re: [Boost-users] Spawning a thread on a member function
And what will happen if the member function takes some additional parameters? e.g. one has void run(const std::string& cs) { // thread job goes here } Should I use nested boost::bind calls? Thanks a lot for help. Pshemek Kind regards Pshemek Przemyslaw Sliwa Global Foreign Exchange FX Risk Engine Development Merrill Lynch ( +44 (0)20 7995 4182 ) +44 (0)79 6325 2319 * Email: przemyslaw_sliwa@ml.com -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Patrick Sent: 27 January 2006 15:53 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Spawning a thread on a member function Hello Sliwa, This should do it. class Simple { Simple() : th(boost::bind(&Simple::run, boost::ref(*this))) {} void run() { for(;;){ //Thread's work goes here. } } private: boost::thread th; }; _____ From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Sliwa, Przemyslaw (London) Sent: Friday, January 27, 2006 4:25 AM To: boost-users@lists.boost.org Subject: [Boost-users] Spawning a thread on a member function All, Does anyone know how to spawn a thread on member function of an existing object in its constructor. Clearly simple boost::bind does not work. I do not know how to tell the compiler it must take the member function. Thanks for help, Pshemek Kind regards Pshemek Przemyslaw Sliwa Global Foreign Exchange FX Risk Engine Development Merrill Lynch *** +44 (0)20 7995 4182 * +44 (0)79 6325 2319 *** Email: przemyslaw_sliwa@ml.com _____ If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here http://www.ml.com/email_terms/ for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ _____
participants (1)
-
Sliwa, Przemyslaw (London)