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 valgrind
You 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-dev
pip3 install prettyc
Or, in modern way
python3 -m venv ${HOME}/pyenv
${HOME}/pyenv/bin/pip install prettyc
cp ${HOME}/pyenv/bin/prettyc ${HOME}/bin
mkdir build && cd build
cmake ..
make menu
make all
To delete CMake cache to reset options to thei'r default values:
make fresh
make menu