Alex
Alex

Reputation: 13126

What is the difference between Coroutine, Coroutine2 and Fiber?

There are 3 thin threads with manual low-latency context switching in the Boost:

What is the difference between Coroutine1, Coroutine2 and Fiber in Boost?

Upvotes: 16

Views: 5327

Answers (1)

xlrg
xlrg

Reputation: 2109

boost.coroutine is non-C++11 and therefore requires to use a private API from boost.context (reason because it is deprecated).

boost.coroutine2 and boost.fiber require C++11 and use callcc()/continuation (implements context switch, call-with-current-continuation) from boost.context.

boost.coroutine and boost.coroutine2 implement coroutines, while boost.fiber provides fibers (== lightweigt, coroperative userland-threads, green-threads, ...) with an API similar to std::thread.

The difference between coroutines and fibers is described in N4024: Distinguishing coroutines and fibers - in short: fibers are switched by an internal scheduler while coroutines use no internal scheduler.

Upvotes: 44

Related Questions