views:

82

answers:

2

Which way is better for a novice student who has never used boost?

When a new standard arrives, the answer will be obvious, but now I have doubts. Pro for boost is that it's much closer to future standard.

+6  A: 

Another pro for Boost is that it uses common C++ idioms for describing, initializing, running, and joining threads (using idioms like RAII and allowing the use of functors and similar C++-specific tools).

Lower-level libraries like APR rely on the use of C-like idioms, which for a C++ developer can prove to be more error-prone (such as the use of function pointers).

In my opinion, Boost::Thread is easier to use because it allows me to use the C++ idioms that I use elsewhere in my code. With APR, I may as well be using pthreads.

greyfade
+1. APR looks like it is pretty much just pthreads with different function names. A lot of threading headaches can be removed (many will remain) by using the C++ and RAII idioms provided by boost. If you used APR with C++, you would probably end up creating many of the same wrappers that boost already provides.
Jason
Ok, thank you. You've exploded my doubts.
flashnik
+1  A: 

As boost::thread can be seen as the draft for the comming standard library implementation of threads, using it and maybe replace it by std::thread in some years might be the best thread library to know first.

Klaim