Common: Polish Fiber class, add comments, asserts and more tests.

This commit is contained in:
Fernando Sahmkow
2020-02-05 15:48:20 -04:00
parent 8d0e3c5422
commit be320a9e10
5 changed files with 147 additions and 25 deletions

View File

@ -18,6 +18,18 @@ namespace boost::context::detail {
namespace Common {
/**
* Fiber class
* a fiber is a userspace thread with it's own context. They can be used to
* implement coroutines, emulated threading systems and certain asynchronous
* patterns.
*
* This class implements fibers at a low level, thus allowing greater freedom
* to implement such patterns. This fiber class is 'threadsafe' only one fiber
* can be running at a time and threads will be locked while trying to yield to
* a running fiber until it yields. WARNING exchanging two running fibers between
* threads will cause a deadlock.
*/
class Fiber {
public:
Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter);
@ -53,8 +65,6 @@ private:
static void FiberStartFunc(boost::context::detail::transfer_t transfer);
#endif
struct FiberImpl;
SpinLock guard;