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:

Anonymous said...

Thanks.

Unknown said...

Not wasted at all! Ta!

Unknown said...

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.

Mortoc said...

Thanks! This page served its purpose perfectly for me.

Anonymous said...

Thanks! Wasnt a waste of time.

Anonymous said...

Thanks :)

Anonymous said...

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

Robin said...

Thanks !

Anonymous said...

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.

Anonymous said...

Thanks! not wasted time ;)

Visionist said...

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

Anonymous said...

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

nana said...

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

Anonymous said...

Thanks. This was exactly what I was looking for.

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

Anonymous said...

Thanks alot

Anonymous said...

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

Fat64 said...

Another thanks :D

Joseph Kogut said...

Thanks for the tutorial. Something human readable, win!

Anonymous said...

Thank you very much.

kroiz said...

Me too. (-:
Thanks a lot.

Anonymous said...

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! :)

Unknown said...

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

Anonymous said...

Thank you!!

Anonymous said...

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.

Anonymous said...

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. :^)

Viewer of Media said...

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

Miser said...

Thanks a lot !

Anonymous said...

thanks!!

John K said...

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!

Unknown said...

Thank you !

Anonymous said...

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

Good Times said...

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

Anonymous said...

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

Mark Chadwick said...

Still working after 2.5 years! Thanks Ilya!

Anonymous said...

Many thanks
this is exactly what I am looking for!

Anonymous said...

youuuuuuuu rock. made my search quite easy

Luiz said...

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

Unknown said...

Still not wasted! :)

George said...

thanks!

Gabor said...

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

Dolan said...

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

Anonymous said...

Thanks :-)

Anonymous said...

Thanks!

Anonymous said...

Still paying off. Thanks!

Anonymous said...

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

Gavin said...

+1, your idea worked. Came from Google.

Anonymous said...

Thanks a lot, still working!!

Anonymous said...

As everyone else says - thanks! :P

Anonymous said...

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!

Anonymous said...

thanks

MIlan Gavrovic said...

Still kickin; !!!
Good work Sir!

Nils said...

Thanks bro!

Anonymous said...

Usefull post ... thanks man!

Anonymous said...

March 2012 and still useful.

Thanks!

André said...

July/2012...

... and still usefull.

Ivan said...

Great! Thank you :-)

Anonymous said...

6 years after... thanks ;)