问题描述
我读在我看来,与Boost.Fiber C ++是越来越接近Erlang的有成千上万的流程的能力,也被称为绿色工艺[主题]http://en.wikipedia.org/wiki/Green_threads.
I am reading http://olk.github.io/libs/fiber/doc/html/ It seems to me that with Boost.Fiber C++ is coming closer to Erlang's ability to have thousands of "processes", also known as "green processes[threads]" http://en.wikipedia.org/wiki/Green_threads.
我的问题是,是Boost.Fiber为生产做好准备,是否有现在 C ++有更好的文档和示例的选择吗?有人提到轻量级线程,但我似乎无法找到它的一个引用。最后一个问题是,为什么不C ++标准包括纤维?
My question is, is Boost.Fiber ready for production, are there now c++ alternatives that have better documentation and examples? Someone mentioned lightweight threads, but I can't seem to find a reference to it. One final question is, why doesn't the C++ standard include Fibers?
我感兴趣的原因是因为我有实时更新,其中的数值变化可能会影响小,但尴尬的并行计算(卵),上百/ thousans。 C ++的线程模型并不能很好地工作,海事组织。请没有GPU,因为它目前的时间太长将信息传送到从GPU。
The reason I am interested in this is because I have realtime updates where a value change can impact (spawn) hundreds/thousans of small but embarrassingly parallel computations. The C++ thread model doesn't work very well, imo. Please no GPU, since it currently takes too long to transfer the information to and from the GPU.
我认识到,Erlang是远不止此,所以请不要教育我在二郎VS C ++在一般情况下。
I realize that Erlang is far more than this so please don't educate me on Erlang vs C++ in the general case.
推荐答案
Boost.Fiber是由Boost社区在2014年1月审查,并发现需要显著额外的工作。看到社区审查结果在http://lists.boost.org/boost-announce/2014/01/0393.php.
Boost.Fiber was reviewed by the Boost community in January 2014 and was found to need significant additional work. See the results of the community review at http://lists.boost.org/boost-announce/2014/01/0393.php.
C ++ 17看起来也来获得的WinRT像L:使用建议等待关键字ñ线程模型根据各地断点续传功能。微软已在其编译器魔术内存分配技巧期货看上去非常有希望实现的支持,并分开。在的N个文件是N4134(http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4134.pdf),并且你会看到,如果接受的断点续传功能,这一提法确实会提供即使语法有点钝二郎山类型的可扩展性(嘿,这是C ++的时候,就是它的语法简单过!)。
C++ 17 also looks to gain a WinRT like M:N threading model based around resumable functions using the proposed await keyword. Microsoft have implemented support in their compiler, and apart from magic memory allocation tricks for futures it looks very promising. The relevant N paper is N4134 (http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4134.pdf), and as you will see that if accepted, this formulation of resumable functions would indeed provide Erlang type scalability even if the syntax is a bit obtuse (hey, it's C++, when is its syntax ever straightforward!).
当然,如果你现在需要一个便携式解决方案,无论是去与ASIO的无堆叠协程航线(这是脆慎用)的事情,或者使用Boost.Fiber反正。如果你只需要的Windows,我会提前与微软的专有扩展preSS自己,他们是高度不同于抛弃他们,除非他们放弃的WinRT:)
Of course, if you need a portable solution now, either go the stackless coroutine route with ASIO (caution: it's brittle), or finely grain ASIO handlers with ASIO strands using a class instance as your execution state which is much the same thing, or else use Boost.Fiber anyway. If you only need Windows, I'd press ahead with Microsoft's proprietary extensions myself, they are highly unlike to abandon them unless they abandon WinRT :)
编辑: Boost.Fiber的作者告诉我说,2015年1月从社区审查建议的更改是完整的,而且除了文档改进纤维被认为是准备纳入官方的推动作用。如果事实确实如此,那么光纤可能是官方的C ++进行最后的断点续传功能,17语言支持出现在编译器之前的最佳解决方案。
The author of Boost.Fiber tells me that as of January 2015 the recommended changes from the community review are complete, and apart from documentation improvements Fiber is considered ready for inclusion into official Boost. If this is indeed the case, then Fiber is probably the best solution before official C++ 17 language support for final resumable functions appears in compilers.
这篇关于随着Boost.Fiber做C ++来一步步接近Erlang的作风进程/线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!