C non-blocking IO without blocking wait functions and callbacks.
Yes, Duff's device allows simulating coroutine in C.
- A simple module system to easily extend.
- Builtin
epoll(7)module. - Builtin
select(2)module. - Builtin
io_uring(7)module using liburing.
Here is a minimal caio coroutine:
struct bar {
int baz;
};
ASYNC
foo(struct caio_task *self, struct bar* state) {
CAIO_BEGIN(self);
/* Do something with state */
state->baz++;
CAIO_FINALLY(self);
}
int
main() {
struct bar state = {0};
return CAIO_FOREVER(foo, &state, 1);
}Which translates to:
void
foo(struct caio_task *self, struct bar* state) {
switch (self->current->line) {
case 0:
/* Do something with state */
state->baz++;
case -1:
}
self->status = CAIO_TERMINATED
}sudo apt install cmake cmake-curses-gui build-essential valgrindYou may disable the io_uring module via make menu variable
CONFIG_CAIO_URING. if not, you need to install these packages to compile the
project and access to io_uring manuals.
apt install liburing2 liburing-devpip3 install prettycOr, in modern way
python3 -m venv ${HOME}/pyenv
${HOME}/pyenv/bin/pip install prettyc
cp ${HOME}/pyenv/bin/prettyc ${HOME}/binmkdir build && cd build
cmake ..
make menu
make allTo delete CMake cache to reset options to thei'r default values:
make fresh
make menu