libxtc
Asynchronous concurrency for C, in the tradition of Tokio, Seastar, and the BEAM: fibers, an event loop, lightweight processes with links and monitors, supervisors, and deterministic simulation testing.
libxtc gives a C program the concurrency model that made Go, Rust/Tokio, Seastar, and Erlang/OTP productive – without asking you to leave C. You write ordinary straight-line functions; libxtc runs them on fibers over an event loop, so a call that would block instead yields, and one OS thread drives thousands of concurrent activities. On top of that sit Erlang-style processes that own their state and communicate only by message, with links, monitors, and supervisors for failure handling.
This manual is written to be read front to back the first time – like
an O’Reilly guide – and used as a reference afterward, like the
BerkeleyDB manual. Every code block on these pages is a real file under
docs/_includes/snippets/
that is compiled and run as part of the test suite, so nothing you copy
from here can silently rot against the API.
The book
Part I – Guide (read in order)
- Getting started – install, build, and run your first coroutine; the anatomy of a libxtc program.
- Fibers and the event loop – how
xtc_async,xtc_yield, andxtc_awaitactually work, and why a fiber is not a thread. - Processes and messages – spawn, send, receive; the shared-nothing discipline.
- Links, monitors, and supervisors – letting things crash, and cleaning up when they do.
- Blocking work and I/O – files, sockets, timers, and how to call a blocking C API without stalling the loop.
- Thinking in libxtc – the mental shifts for a C/C++/Rust programmer, and the anti-patterns that bite.
Part II – Reference
- Architecture and the layer model – L0 through L5 and what each layer owns.
- The public API – the shape of the
xtc_*surface. - Locks and synchronization – which primitive to reach for.
- Manual pages – every
xtc_*function, by section. - Debugging and observing – GDB/LLDB recipes and runtime introspection.
- ABI stability – what stays fixed across releases.
- Known issues – honest caveats and workarounds.
Part III – The example programs
The examples/ directory ships whole programs – a Redis
work-alike, a Kafka-shaped log broker, a from-scratch SQL engine – each
built on libxtc. The Examples section explains what each
one is, the design decisions behind it, and the trade-offs it makes.
Part IV – Philosophy
- Why libxtc exists – the problem, and the shape of the answer.
- Choices and roads not taken – the alternatives we deliberately did not choose, and why.
Build and platform matrices
Source and license
- Git: https://codeberg.org/gregburd/libxtc (mirror: https://github.com/gburd/libxtc)
- License: ISC. See LICENSE.