Passing an argument to threads (boost::thread)
Hello, How to pass arguments to a thread? From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this); However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments Thanks, Jean
On Sat, Aug 23, 2008 at 2:22 PM, Jean-Sebastien Stoezel
Hello,
How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
new boost::thread(boost::bind(&MyClass::ProcessorListener, this)); -- Cory Nelson
Hi, Here's the error I get after the code modifications: 'bind' : is not a member of 'boost' I'm compiling with boost 1.35 On 23-Aug-08, at 5:29 PM, Cory Nelson wrote:
On Sat, Aug 23, 2008 at 2:22 PM, Jean-Sebastien Stoezel
wrote: Hello,
How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
new boost::thread(boost::bind(&MyClass::ProcessorListener, this));
-- Cory Nelson _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jean-Sebastien Stoezel skrev:
Hi,
Here's the error I get after the code modifications:
'bind' : is not a member of 'boost'
#include
Jean,
I'm not familiar with Boost.Thread yet, but the documentation for 1.36.0 suggests you can call the thread constructor with multiple arguments as you're doing. Docs for 1.35.0 don't mention that constructor so I wonder if you're using 1.35.0 or before, but reading documentation for 1.36.0?
As suggested by others, boost::bind looks like it'll help.
Regards,
Pete
--- On Sat, 23/8/08, Jean-Sebastien Stoezel
From: Jean-Sebastien Stoezel
Subject: [Boost-users] Passing an argument to threads (boost::thread) To: boost-users@lists.boost.org Date: Saturday, 23 August, 2008, 10:22 PM Hello, How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
Thanks, Jean
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
on Sat Aug 23 2008, Jean-Sebastien Stoezel
Hello,
How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
I'm just curious: is there some good reason you've chosen to dynamically allocate thread objects? -- Dave Abrahams BoostPro Computing http://www.boostpro.com
yes On 24-Aug-08, at 7:23 PM, David Abrahams wrote:
on Sat Aug 23 2008, Jean-Sebastien Stoezel
wrote: Hello,
How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
I'm just curious: is there some good reason you've chosen to dynamically allocate thread objects?
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Well ... enlighten us please!
I'm curious too.
Thanks
Andrew
On Mon, Aug 25, 2008 at 10:50 AM, Jean-Sebastien Stoezel
yes
On 24-Aug-08, at 7:23 PM, David Abrahams wrote:
on Sat Aug 23 2008, Jean-Sebastien Stoezel
wrote: Hello,
How to pass arguments to a thread?
From the documentation I thought I could do this: mp_ProcessorListenerThread = new boost::thread(ProcessorListener, this);
However I get the following error: 'boost::thread::thread' : no overloaded function takes 2 arguments
I'm just curious: is there some good reason you've chosen to dynamically allocate thread objects?
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- ___________________________________________ Andrew J. P. Maclean Centre for Autonomous Systems The Rose Street Building J04 The University of Sydney 2006 NSW AUSTRALIA Ph: +61 2 9351 3283 Fax: +61 2 9351 7474 URL: http://www.acfr.usyd.edu.au/ ___________________________________________
participants (6)
-
Andrew Maclean
-
Christian Larsen
-
Cory Nelson
-
David Abrahams
-
Jean-Sebastien Stoezel
-
Peter Barker