User-level threading library inspired by ironport/shrapnel.
Based on standard POSIX ucontext.h interface and the concept of coroutines. Implements event-driven thread context switch using the libev -based poller. On FreeBSD, where it was originally developed, the kqueue(2) -based poller can be used as an alternative to libev.
Features:
-
basic threads management: create and schedule threads for run, request thread's interruption;
-
FreeBSD only: x86 rdtsc-based internal clock, calibrated by gettimeofday(2) and the machdep.tsc_freq sysctl;
-
basic thread synchronization primitives: signal, semaphore, condition variable, reader-writrer lock;
-
have a thread join another thread until the latter one completes its execution;
-
have a thread wait for another thread until a specified period of time elapses, or the latter one completes, whichever occurs first;
-
wrappers over read(2), write(2), accept(2), sendto(2), recvfrom(2) syscalls;
-
relatively good performance and scalability, derived from the underlying libevent and ucontext features.
Limitations:
- unlike ironport/shrapnel, cannot scale on 32-bit platforms because of virtual address space limit.
Dependencies: mkushnir/mncommon.
The porject is gradually getting mature.
-
more testing;
-
more documentation;
-
more functionality;