How gerold103/serverbox works
Project Type and Purpose
• This is a C++ framework (library) for high-performance asynchronous networking and task scheduling, analogous to Boost.Asio but far more compact and optimized.
• Core modules:
• IOCore (async networking/event loop)
• TaskScheduler (multi-threaded async task engine)
• net and sio modules (socket abstractions)
• Supporting components: benchmarks (bench/), examples (examples/), unit tests (test/), formal specs (tla/), build/config (CMake, GitHub Actions).
High-Level Directory Structure and Architectural Patterns
• Low-level utilities (Atomics, Queues, Mutexes, Coroutines, Logging)
• Provides foundational primitives used everywhere else.
• src/mg/net:
• Protocol-agnostic I/O buffers, URL resolution, SSL abstractions.
• src/mg/sio:
• Simple socket and TCP server/client wrappers.
• src/mg/sch:
• TaskScheduler engine (tasks, scheduling queues).
• src/mg/aio:
• IOCore event loop, socket subscription interface, support for epoll, io_uring, kqueue, IOCP.
• src/mg/stub:
• test/:
• Unit tests for each module using CMake-driven test executables.
• bench/:
• Performance benchmarks for IOCore, MPSC/MPSC queues, TaskScheduler, I/O modes.
• examples/:
• Sample applications demonstrating TCP hello, SSL, pipelines, periodic tasks, coroutine tasks, interacting tasks.
• tla/:
• TLA+ specifications for core algorithms (TaskScheduler, MCSPQueue, InterruptibleMutex).
Core Components and Interactions
• Atomic queues, thread pools, condition variables, coroutines form the base.
b. net → sio & aio
• Core networking (Buffer, Socket, SSLContext) feeds into simplified I/O wrappers and the IOCore engine.
c. sch → aio
• TaskScheduler’s queueing and thread-dispatch logic is shared by IOTasks in IOCore.
d. aio ↔ OS kernel
• Event sources (epoll, io_uring, kqueue, IOCP) drive IOTasks, which then schedule callbacks via the scheduler.
e. Applications (examples/) and tests (test/) link against these libraries.