在C ++中有没有跨平台线程库? [英] Is there any cross-platform threading library in C++?

查看:182
本文介绍了在C ++中有没有跨平台线程库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您对的看法:boost :: thread Pthreads
Pthread只在POSIX兼容系统上运行?



Qt 库中的线程支持?

解决方案

Boost.Thread是C ++语言的标准线程库的草稿。知道了,我更喜欢使用它,因为它提供了一些有力的保证(因为它成为标准)。



更新:现在我们有标准的线程库, 。一些boost构造,如boost :: shared_mutex,尚未标准化(但可能稍后)。然而标准库更好地利用了移动语义。在选择图书馆之前很了解。此外,使用C ++ 11线程库需要一个提供它的编译器。现在并不是所有编译器的情况。



更新:
现在[Nov2012]大多数标准编译器提供C ++ 11线程库。 VS2012,GCC4.8和Clang3.1支持线程和同步原语和原子操作。
为了完整的实现,你也可以使用Anthony Williams的线程。它是Windows / Mac和Linux上支持的C ++ 11兼容库。



各种编译器的C ++ 11功能的状态链接:




I'm looking for some easy to use cross-platform threading library written in C++.

What's your opinion on boost::thread or Pthreads? Does Pthreads run only on POSIX compliant systems?

What about the threading support in the Qt library?

解决方案

Boost.Thread is the draft for the coming standard threading library of the C++ language. Knowing that, I prefer to use it as it provide some strong guarantees (because it becomes standard).

Update: Now that we have the standard threading libraries, some more precisions. Some boost constructs, like boost::shared_mutex, have not been standardised (but might be later). However the standard library exploit the move semantic better. Good to know before choosing a library. Also, using C++11 threading library requires a compiler that provides it. It's not the case for all compilers today.

Update: Now [Nov2012] most of the Standard compilers provide C++11 threading library. VS2012, GCC4.8 and Clang3.1 have support for threads and synchronization primitives and atomic operations. For complete implementation you can also use just thread by Anthony Williams. It is C++11 compliant library supported on Windows/Mac and Linux.

Links for status of C++11 features with various compilers:

这篇关于在C ++中有没有跨平台线程库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆