We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
如果您的目标主要是加速计算速度,英特尔的 TBB(线程构建模块)是(恕我直言)比从
boost::thread
滚动您自己的劣质版本更好的选择。If your aim is primarily speeding up compute things, Intel's TBB (Threading Building Blocks) is (IMHO) a better option than rolling your own inferior version from
boost::thread
.这个问题以及一般的谷歌搜索“C++协程”应该给你一些接近的东西。 SO问题建议尝试Boost::coroutine。
如果您不介意封装 C,您也许可以尝试libtask。这是由 Russ Cox(Go 官方开发团队之一)在 Go 工作开始之前编写的。我只在C语言中使用过它,所以我不知道它是否适用。
顺便说一句,Go 通道被实现为锁定队列,因此您可以使用常规线程合并类似的机制。
This question and in a general a google search for "C++ coroutines" should get you something close. The SO question suggests trying Boost::coroutine.
If you don't mind wrapping C you might be able to try libtask. Which was written by Russ Cox (one of the official Go dev team) before work on Go began. I've only used it in C though, so I don't know if it's applicable.
Go channels are implemented as locking queues by the way, so you might be able to incorporate a similar mechanism using regular threads.
coost
一个 go 风格的 C++ 协程库。
它还提供:
coost
A go-style C++ coroutine library.
It also provides:
尝试 GBL 库,它拥有一切:协程(纤程)、线程、同步和异步处理程序 - 而且它是所有现代C++。
Try GBL library, it has everything: coroutines (fibers), threads, sync and async handlers -- and it's all modern C++.
libgolang 提供
go
和渠道,包括工作选择
。以下是示例用法:go
根据激活的运行时生成线程或基于 gevent 的协程。libgolang provides
go
and channels including workingselect
. Here is example usage:go
spawns either a thread or gevent-based coroutine depending on activated runtime.从我目前所见, cilk 似乎与 go 的并行风格非常相似。看起来英特尔已经收购了它并通过Intel Cilk Plus<提供商业支持/a>.
From what I have seen so far, cilk seems to be quite similar to go's style of parallelism. It looks like Intel has bought it and provides commercial support with Intel Cilk Plus.