Async tasks in 350 lines of C
Async tasks in 350 lines of C
Tasks are a primitive for asynchronous programming and an alternative to working with threads directly. Instead of creating a thread, performing work, then waiting on it using synchronization primitives, you only define a unit of work and let a scheduler decide when and where to execute it. The threads that the scheduler uses are created once and reused for many tasks throughout the program's lifetime. In most cases, creating and executing a task requires not even a single syscall and is a significantly faster operation than creating a thread, resulting in lower latency. Furthermore, tasks from different subsystems can be automatically interleaved by the scheduler, which is difficult to achieve manually with threads without communication between the subsystems. The library is written in standard C11 and only depends on the C POSIX library. It is designed to be easy to integrate into a project by just copying the header and simple enough to be understood in an afternoon.
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Spinning Cube in 45 lines, 45 Chars Each
Flappy Bird in 128 Lines of CoffeeScript
Own MobX in 65 lines of code
Implement MFA in two lines of code
Wavelet video codec in less than 5000 lines of C
3 lines to hook into ethereum data streams
Upgrade Charm Crush with search in 9 lines
MathGPT for numerical modelling software – lines combined method
HingeGPT – Generate mediocre Hinge opening lines
Lines, the free London Underground app