Commit a0f21242 authored by Markus Lindelöw's avatar Markus Lindelöw
Browse files

Add explanation of fiber system

parent 8cba444c
Loading
Loading
Loading
Loading
+9 −1
Changes for README.md: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
tinyfiber
============
A cooperative lightweight multithreading system. 
A cooperative lightweight job-system with a C-api. This library uses a N:M mapping between working threads and fibers. You can have thousands of fibers running from a thread pool without ever have a kernel thread switch.

Online documentation: https://tinyfiber.readthedocs.io/

This library currently only supports Windows.

```cpp
#include "tinyfiber.h"
@@ -30,3 +34,7 @@ void job(void* param)
    }
}
```

A fiber system is a way to switch thread without involving the kernel. This makes the switches fast with a low over-head. A fiber can be seen as a data structure containing the current execution context, i.e. the states of the registers and a stack, importantly this includes the instruction pointer.

A fiber switch will not change thread, which means that a working pool of threads can exchange fibers. This means that you can not trust local thread storage variables between yields; mutex and semaphores will not work. This also includes all 3:rd part library functions you may call. If your project needs to use TLS in a matter that is not compatible with these constraints I recommend that you consider UMS (User-Mode Scheduling) or C++20 coroutines instead.