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.

Get started API reference


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)

  1. Getting started – install, build, and run your first coroutine; the anatomy of a libxtc program.
  2. Fibers and the event loop – how xtc_async, xtc_yield, and xtc_await actually work, and why a fiber is not a thread.
  3. Processes and messages – spawn, send, receive; the shared-nothing discipline.
  4. Links, monitors, and supervisors – letting things crash, and cleaning up when they do.
  5. Blocking work and I/O – files, sockets, timers, and how to call a blocking C API without stalling the loop.
  6. Thinking in libxtc – the mental shifts for a C/C++/Rust programmer, and the anti-patterns that bite.

Part II – Reference

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

Build and platform matrices

Source and license