简体   繁体   中英

std::thread in C++ vs. goroutine in go language?

The nature of gorouting in go language is an automatic fiber/coroutine.

The nature of std::thread in C++ is a wrapper of native threads.

I think std::thread should be an abstraction of parallel works, not just for native threads. In cloud computing era, it's very important.

Is there any way to use std::thread like the following:

std::thread<GoroutingStyle>    t1;
std::thread<NativeThreadStyle> t2;

Or if not, does the C++ standard consider to add some features/libraries to support goroutine?

Or if not, does the C++ standard consider to add some features/libraries to support goroutine?

what you are requesting is something like a fiber library - the forthcoming library boost.fiber contains cooperatively scheduled fibers, mutexes/condition-vairables/barriers/... - the interface is similar to boost.thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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