1.19.2011

Lest we forget...

This blog entry is so I don't forget how to do threading using the Boost C++ Libraries using Eclipse in Linux.  Oh, and anybody else who's had odd problems.

So, basically, the goal here is to link to boost_thread.  I'm going to assume you've already gotten libboost-all from the repositories.

  1. Right click on the project you want to do threading in.
  2. C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries.
  3. In the top panel, add an entry for "boost_thread"
Ta da!  It and all it's magical goodness work!

Just for fun, here's the code for basic threading:
// Start the thread
boost::thread workerThread(doWork);
// Pause this thread until workerThread is done
workerThread.join();
Note that we don't really need to "join" the thread.  workerThread will go off and do it's own thing, even if we do our own.

Happy threading!

    No comments:

    Post a Comment