开发者

Multithreading: apache portable runtime vs boost::thread?

开发者 https://www.devze.com 2022-12-25 03:17 出处:网络
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 st

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 stan开发者_C百科dard.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号