Repolode
idealvin

idealvin/coost

A lightweight C++ base library bundling goroutine-style coroutines, networking, logging, flag parsing, JSON, unit testing and benchmarking.

Stars
4,225
Forks
593
Open issues
0
Last commit
27 days ago

What is it?

coost is a C++ base library that bundles the infrastructure components a C++ service typically needs into one dependency. It targets Linux, macOS, Windows, FreeBSD, and x86, x64, ARM and ARM64 CPUs.

The library provides go-style coroutines that are scheduled across threads by default, with shared stacks to keep memory use low. On top of them sit a coroutine-based socket API, a TCP server and client wrapper, and a simple JSON-based RPC framework. Other components include a logger that prints stack traces on crashes, a flag parser for command-line arguments and config files, a JSON type with a fluent interface, a unit testing framework, and a benchmark framework.

Code is organized into headers under include/, sources under src/ compiled into libco, and tests under unitest/. The project recommends xmake for building and also supports CMake. It requires a C++17 compiler.

Key features

  • 01Go-style coroutines scheduled across threads, with shared stacks for low memory use.
  • 02Coroutine-based socket API, TCP server/client wrapper with IPv6 support, and a JSON-based RPC framework.
  • 03Logger that prints stack traces on crashes and supports runtime assertions.
  • 04Flag parsing for command-line arguments and config files, with aliases and automatic config generation.
  • 05Built-in JSON type with a fluent interface, plus unit testing and benchmark frameworks.

Use cases

  • Building high-performance C++ network services on coroutines without callback-heavy code.
  • Adding fast, crash-aware logging to C++ applications.
  • Parsing command-line flags and config files in C++ tools.
  • Replacing a collection of separate base libraries with one dependency.

Quick start

  1. 1

    Install the xmake build tool from its project page

  2. 2

    From the coost root directory, build libco

    xmake
  3. 3

    Build the unit test program

    xmake b unitest
  4. 4

    Run all unit test cases

    xmake r unitest

Things to know

  • Requires a compiler with C++17 support.
  • Some bundled code comes from other projects and may use different licenses.

In collections

Topics

FAQ

What is coost?
A lightweight C++ base library bundling goroutine-style coroutines, networking, logging, flag parsing, JSON, unit testing and benchmarking. coost is a C++ base library that bundles the infrastructure components a C++ service typically needs into one dependency. It targets Linux, macOS, Windows, FreeBSD, and x86, x64, ARM and ARM64 CPUs.
Is coost free to use? What license does it have?
coost is open source under the Other license. Check the license terms before using it in commercial products.
Is coost still maintained?
Actively maintained. The last commit to coost was on Sep 28, 2026.
What can I use coost for?
Building high-performance C++ network services on coroutines without callback-heavy code. Adding fast, crash-aware logging to C++ applications. Parsing command-line flags and config files in C++ tools. Replacing a collection of separate base libraries with one dependency.
How do I install coost?
Install the xmake build tool from its project page From the coost root directory, build libco: xmake Build the unit test program: xmake b unitest Run all unit test cases: xmake r unitest
Where can I get coost?
The source code and installation instructions are on GitHub: https://github.com/idealvin/coost

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects