go语言中gorouting的本质是一个自动的fiber/coroutine。
C++ 中 std::thread 的本质是对 native 线程的包装。
我认为 std::thread 应该是并行工作的抽象,而不仅仅是针对原生线程。在云计算时代,它非常重要。
有没有办法像下面这样使用 std::thread:
std::thread<GoroutingStyle> t1;
std::thread<NativeThreadStyle> t2;
或者如果没有,C++ 标准是否考虑添加一些功能/库来支持 goroutine?
最佳答案
Or if not, does the C++ standard consider to add some features/libraries to support goroutine?
您所请求的是类似于纤程库的东西 - 即将推出的库 boost.fiber 包含协作调度的纤程、互斥锁/条件变量/障碍/... - 接口(interface)类似于 boost.thread。
关于c++ - C++ 中的 std::thread 与 Go 语言中的 goroutine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18557916/