Search:
Forum
UNIX/Linux Programming
a question about boost thread
a question about boost thread
Sep 29, 2009 at 6:00pm UTC
mamali
(9)
hi everyone
i want to write a multithread program with libboost_thread but the problem is that it only supports functions with no arguments what should i do if iwnat to use it with arguments ?
Oct 1, 2009 at 3:44pm UTC
j34w14b
(1)
i believe you can use the bind() function provided by the boost::bind library
boost::thread your_thread( boost::bind(&your_function, param1, param2, .....) );
In this way, you can bind parameters to the function and they will be passed in as normal.
Last edited on
Oct 2, 2009 at 11:11am UTC
Oct 2, 2009 at 6:34pm UTC
PanGalactic
(1658)
Newer versions of the Boost Thread Library permit this without using bind().
Search for "Thread Constructor with arguments" at
http://www.boost.org/doc/libs/1_40_0/doc/html/thread.html
But a solution for older versions of Boost is to use a functor and pass the arguments to its constructor. Example here:
http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs