Wednesday, July 25, 2007

boost::thread and boost::mutex tutorial

For most Boost's libraries its documentation requires you to read everything from the start to the end before you can write any code. Compare that with most of CPAN modules where usually you can start using CPAN module after quickly scanning synopsis and maybe description parts of it's POD documentation. POD documentation as a rule has good examples right on top of the page. Boost's documentation usually doesn't.

So I was looking for basic usage examples for boost::thread and boost::mutex classes and initially I couldn't find any because I was using wrong search keywords. In the end I figured out how to use boost::thread and boost::mutex classes in my application hard way by reading Boost documentation without relying on any examples. But afterwards I did find a very good article on this topic with many simple examples: The Boost.Threads Library on Dr.Dobb's. So I'm posting this link here for google. It is in top 10 hits for some relevant keywords but it is not for others (for example for boost thread mutex tutorial) and this is why I missed it initially. If my blog post helps any Boost.Threads newbie to get started then I would consider time spent writing this post to be not wasted.

57 comments:

  1. Thanks, your time was definitely not wasted and in fact has helped save time for at least one poor sap working his way through the Boost.Thread documentation.

    ReplyDelete
  2. Thanks! This page served its purpose perfectly for me.

    ReplyDelete
  3. Thanks! Wasnt a waste of time.

    ReplyDelete
  4. Looks like you might have helped me a lot there too mate. Thanks a lot :D

    ReplyDelete
  5. Thanks! I had been searching for stuff on C++ threads and hadn't found a good article or tutorial on them until I typed in "C++ threads boost tutorial" and got your page and followed the link.

    ReplyDelete
  6. Thanks! not wasted time ;)

    ReplyDelete
  7. Thanks! This is a good place to drop by when searching for Boost.Thread tutorial.

    ReplyDelete
  8. Thank you very much. Your link is very useful:)

    ReplyDelete
  9. Thanks a lot for your link though the article seems a bit obsolete now.

    I also found a good article here:
    http://blog.emptycrate.com/node/277

    Cheers

    ReplyDelete
  10. Thanks. This was exactly what I was looking for.

    Pitty the Boost.org people can't write examples on their own. ;o)

    ReplyDelete
  11. I got the same feeling with you while looking for a pratical, handy guide of boost thread, now I found this tutorial. So, thanks.

    ReplyDelete
  12. Thanks for the tutorial. Something human readable, win!

    ReplyDelete
  13. Thank you very much.

    ReplyDelete
  14. Thanks for this! Definitely quite understandable. There's another quite good tutorial here:

    http://paulbridger.net/multithreading_tutorial

    The problem with that one is that there're no COMPLETE examples - however, it does explain the concepts more thoroughly. :)

    Also, be sure to check out the "What's new in Boost Threads by Dr.Dobb's:
    http://www.ddj.com/cpp/211600441

    Haven't read it yet, but apparently there's stuff about a newer version of the library.

    Happy coding people! :)

    ReplyDelete
  15. thanks ... i feel ya ... i like to learn thru examples

    ReplyDelete
  16. Thanks mate, another quick piece of info on using Boost threads on a class is: http://ubuntuforums.org/showpost.php?p=5392618&postcount=4

    explains how to use to make a class similar to if you inherit from Thread in Java.

    ReplyDelete
  17. Thanks for the link. I was going cross-eyed reading the Boost::Thread docs and it turns out I only needed two extra lines in my code. :^)

    ReplyDelete
  18. It's still the gift that keeps giving.
    And btw, if any readers are C++ newbs like me, and have trouble with the example code, the keys to learn are "Initialization Lists"
    http://www.cprogramming.com/tutorial/initialization-lists-c++.html
    and "functors" or "Thread Functors"
    http://developer.vrjuggler.org/docs/vapor/2.0/programmer.guide/programmer.guide/ch05s02.html

    ReplyDelete
  19. Whoever is responsible for the Boost threads documentation should be ashamed that this blog is the number one hit for boost thread tutorial, and there is nothing on the web for it from boost itself... But thank you blogger!

    ReplyDelete
  20. Thanks! when i searched today you were the number 1 google hit for "boost thread tutorial"

    ReplyDelete
  21. thanks, you pointed out something i've been frustrated by with boost documentation for years and you pointed to the same example i had in mind, CPAN/POD

    ReplyDelete
  22. thanks :p
    It looks like google like your article it's was my 3rd result !

    ReplyDelete
  23. Still working after 2.5 years! Thanks Ilya!

    ReplyDelete
  24. Many thanks
    this is exactly what I am looking for!

    ReplyDelete
  25. youuuuuuuu rock. made my search quite easy

    ReplyDelete
  26. yeah it helped! I never write comments on blog posts, but this one deserves it! Thanks!

    ReplyDelete
  27. Thank you very much, i found this post via google, so it was worth (IMO).
    cheers

    ReplyDelete
  28. Thanks a lot. Saved me hours of time reading docs.

    ReplyDelete
  29. Still paying off. Thanks!

    ReplyDelete
  30. Good stuff mate, and thankyou very much for the Dr Dobbs link. That is exactly what I was looking for.

    ReplyDelete
  31. +1, your idea worked. Came from Google.

    ReplyDelete
  32. Thanks a lot, still working!!

    ReplyDelete
  33. As everyone else says - thanks! :P

    ReplyDelete
  34. Thank you, I was really strugling using the Win32 API for multi-threading but now I use boost which is so much easier once you read the documentation!

    ReplyDelete
  35. Still kickin; !!!
    Good work Sir!

    ReplyDelete
  36. Usefull post ... thanks man!

    ReplyDelete
  37. March 2012 and still useful.

    Thanks!

    ReplyDelete
  38. July/2012...

    ... and still usefull.

    ReplyDelete
  39. 6 years after... thanks ;)

    ReplyDelete