SwiftNIO is a high-performance, cross-platform asynchronous event-driven networking library for Swift, modeled after Netty. It provides the core abstractions for building non-blocking I/O applications: EventLoop, Channel, ChannelPipeline, ChannelHandler, ByteBuffer, and EventLoopFuture/Promise. The library includes in-tree protocol implementations for HTTP/1.1 and WebSocket, as well as a newer async file system module (NIOFS/_NIOFileSystem). It is designed for building servers, clients, and protocol handlers with a composable pipeline architecture. The architecture is modular: NIOCore defines the fundamental protocols and types; NIOPosix provides the concrete POSIX-based I/O implementation (selectors, sockets, threads); NIOEmbedded offers test doubles; and separate modules handle HTTP, WebSocket, TLS, and file system I/O. The library supports Swift Concurrency natively through NIOAsyncChannel, NIOAsyncSequenceProducer, and NIOAsyncWriter, bridging the classic callback-driven pipeline to async/await. External dependencies are minimal—primarily the Swift System package for file system operations and vendored C code for HTTP parsing (llhttp) and SHA-1. Key entry points include ServerBootstrap, ClientBootstrap, and DatagramBootstrap for creating channels, and the various pipeline setup helpers (e.g., configureHTTPServerPipeline). Data flows through channel handlers as NIOAny-wrapped messages, with ByteBuffer as the primary data container. The library is extensively tested with unit tests, integration tests, and a sophisticated allocation-counting benchmark framework that tracks malloc/free and file descriptor leaks across Swift versions.
amphp/amp is a PHP library providing fundamental asynchronous concurrency primitives: Futures (promises) and Cancellations. It is built on top of the Revolt event loop and leverages PHP 8.1 fibers for cooperative multitasking, eliminating the need for generator-based coroutines or callback-heavy APIs. The library offers a Future class with methods like map(), catch(), finally(), and await() for composing asynchronous operations, along with combinators (await, awaitFirst, awaitAny, awaitAnyN, awaitAll) for concurrent execution. Cancellation is handled via a clean interface with implementations for timeouts (TimeoutCancellation), OS signals (SignalCancellation), manual cancellation (DeferredCancellation), and composition (CompositeCancellation). Utility functions include async() for spawning fibers, delay() for non-blocking sleep, trapSignal() for awaiting signals, and weakClosure() to prevent circular references in closures. The architecture is modular, with internal state management separated from public APIs, and strict typing throughout. External dependency is limited to revolt/event-loop for the event loop and suspension API.
lua-resty-redis is a Lua Redis client driver for OpenResty/ngx_lua, leveraging the cosocket API for fully non-blocking I/O. It implements the Redis wire protocol (RESP) to support all standard Redis commands, including pipelining, transactions, pub/sub, and SSL connections. The library provides automatic method generation via Lua metatables, allowing any Redis command to be called as a method without explicit registration. It also offers connection pooling, Unix socket support, and configurable timeouts. The single source file (lib/resty/redis.lua) is self-contained and can be dropped into any OpenResty project. The codebase demonstrates strong engineering practices with efficient table reuse, proper error handling, and comprehensive test coverage.
httpserver.h is a single-header C library for building high-performance, non-blocking, event-driven HTTP servers. It uses epoll on Linux and kqueue on BSD/macOS for I/O multiplexing, and includes a Ragel-generated HTTP parser that handles chunked transfer encoding, content-length bodies, streaming, and keep-alive connections. The library exposes a clean callback-based API: initialize a server with a port and request handler, then call listen to start the event loop. It also supports a poll mode for integration into existing event loops (e.g., game engines). The codebase is well-structured internally, split into separate compilation units that are concatenated into a single header at build time via M4. It includes comprehensive unit tests (using munit), functional tests (shell-driven), fuzz testing, and CI. Production-grade features include memory usage limits, request timeouts, connection management, and chunked response support. The architecture demonstrates strong C craftsmanship with clear separation of I/O, parsing, response formatting, and connection management.