简体   繁体   English

Boost.Thread还是只是:: thread?

[英]Boost.Thread or just::thread?

I am not yet a Boost user. 我还不是Boost用户。 I am however planning to go into it as soon as possible. 但我计划尽快进入。 However I am little concerned about Boost, and the likely future name collisions or differences with the forthcoming C++0x. 但是我很少关注Boost,以及可能的未来名称冲突或与即将到来的C ++ 0x的差异。 (Maybe it is not a real issue, but for example I find the boost lambdas syntax pretty ugly, BOOST_FOREACH aggressive to the eye, and other only aesthetic personal views). (也许这不是一个真正的问题,但是例如我发现提升lambda的语法非常丑陋,BOOST_FOREACH咄咄逼人的眼睛,以及其他唯一的审美个人观点)。

I am really interested by the TR2, which seems to be implemented by the libraries Boost.Thread and just::thread . 我对TR2很感兴趣,它似乎是由Boost.Threadjust :: thread实现的 Both seems to be written and maintained by Anthony Williams. 两者似乎都是由Anthony Williams编写和维护的。

But just::thread claims to be closely compliant with the TR2. 但只是:: thread声称与TR2密切相关。

I wanted to know if any one of you would indicate me to use one or the other. 我想知道你们中是否有人会指示我使用其中一个。 just::thread is not free, but if it was to be really just like TR2, I am tempted. just :: thread不是免费的,但如果它真的像TR2一样,我很受诱惑。

Any thought ? 任何想法 ?

At the present time I am experimenting, on Linux, with the boost, just::thread libraries and the so-called 'experimental' C++Ox features of the gcc g++ 4.5 compiler. 目前,我正在Linux上使用boost,just :: thread库和gcc g ++ 4.5编译器的所谓“实验性”C +​​+ Ox功能进行实验。 With regard to threading I have up to press I have found the code that I have written for just::thread and the g++ compiler to be 100% compatible. 关于线程,我已经按下了,我发现我为just :: thread编写的代码和g ++编译器是100%兼容的。 The boost libraries (1.43) are markedly not compatible with the former two. 增强库(1.43)与前两者明显不兼容。 However, for my production code I use the boost libraries. 但是,对于我的生产代码,我使用了boost库。

Name collision should not be a problem with the correct and judicious use of the available namespaces in boost, just::thread and the g++ compilers. 名称冲突不应该是在boost,just :: thread和g ++编译器中正确和明智地使用可用命名空间的问题。 I have no problem using just::thread with the C++Ox g++ features; 使用just :: thread和C ++ Ox g ++功能我没有问题; indeed it is recommended by just::thread that these features are used, such as variadic templates. 事实上,just :: thread建议使用这些功能,例如可变参数模板。

I think it's too early to say that a library is "just like TR2". 我认为现在说图书馆“就像TR2”还为时过早。 The TR2 will be released after C++0x, which itself hasn't even been released yet. TR2将 C ++ 0x 之后发布,它本身甚至尚未发布。

However, the Boost.Thread library also claims to follow the development in the Standardization Commitee. 但是,Boost.Thread库也声称遵循标准化委员会的发展。

I would prefer any Boost library over its "original", because Boost is committed to high quality and the Boost community maintains libraries collaboratively, as opposed to a private lib that just happened to migrate to boost. 我更喜欢任何Boost库而不是它的“原创”,因为Boost致力于高质量,Boost社区协作维护库,而不是刚刚迁移到提升的私有库。

You don't have to be afraid of name clashes, since what is currently in the boost:: namespace will stay in the namespace, and all TR2 stuff will probably go to std::tr2:: . 您不必担心名称冲突,因为当前在boost:: namespace中的内容将保留在命名空间中,并且所有TR2内容可能都会转到std::tr2::

Best advise at this time - none of the above :-) 目前最好的建议 - 以上都不是:-)

Unless you have an absolutely pressing need, you'll save yourself a lot of time and grief by just waiting till C++0x settles first, which is going to take about 2 yr. 除非你有一个绝对紧迫的需求,否则只要等到C ++ 0x先安定下来,你就可以省去很多时间和悲伤,这需要大约2年。 If someone is asking you to go chasing moving targets - ask to see the money first :-) and a big retainer :-)) 如果有人要求你去追逐移动目标 - 要求先看钱:-)和一个大保留者:-))

Like in many other cases it's best to first ask yourself "what are my actual needs"? 像许多其他情况一样,最好首先问问自己“我的实际需求是什么”? If it's learning multi-threading development, then spending time with C# or Java will be much easier on your nerves. 如果它正在学习多线程开发,那么花时间使用C#或Java会让您更加轻松。 If you need to start developeing a production level system, then you already know your target platform and the best you can do is to stick with whatever is a tried-by-fire lib for multi-threading on your target platform and has full debugger support. 如果您需要开始开发生产级系统,那么您已经了解了您的目标平台,并且您可以做的最好的事情就是坚持使用在目标平台上进行多线程的试用版本的lib并拥有完整的调试器支持。 Just to repeat again - full debugger support and integration is what decides the quaility of you life in the thread land. 再重复一遍 - 完全调试器支持和集成决定了你在线程领域的生活质量。

If you touch Boost, make sure you have enough time to ensure that it doesn't have dependencies on a dozen of other boost-something files and then another dozen ... unless you are afficionado that is :-) If you touch a libraty tht claims automatic dedlock detection be prepared to pay in CPU cycles and deal with potentially unwanted interference. 如果你触摸Boost,请确保你有足够的时间来确保它没有依赖于十几个其他的boost-something文件然后另外打...除非你是afficionado :-)如果你触摸一个libraty声称自动解锁检测准备支付CPU周期并处理可能不需要的干扰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM