ThreadSchedule 4.1.0
Modern C++ thread management library
Loading...
Searching...
No Matches
Development with mcpp

The checkout has a native mcpp build for C++23 development on Linux x86-64 and Windows x86-64. The experimental named module is exercised on Linux in C++23 and C++26. Existing consumers can continue to use C++17 and the public headers through CMake or Conan 2.

Install and build

Use mcpp 2026.11.22.1, the version used in CI. With xlings installed, run the following command in your shell or PowerShell. On Unix, the release page also provides an installer which accepts MCPP_VERSION=2026.11.22.1.

xlings install mcpp@2026.11.22.1 -y -g -u
mcpp --version

Build and test from the ThreadSchedule checkout.

mcpp build
mcpp run getting_started_example
mcpp test --timeout 120
mcpp test --profile release --timeout 120

The manifests pin gcc@16.2.0. mcpp installs the matching compiler, standard library, sysroot and build tools on demand in its own home. The default dev profile is unoptimized with debug information. --profile release selects optimized code and defines NDEBUG. The root mcpp test reuses the C++23 GoogleTest sources with the pinned compat.gtest dependency. Header-only mode is the default. The runtime tests run their cases when the runtime feature is enabled. CMake continues to build the compile-only lifetime diagnostics fixture and run the include-layer check.

mcpp test runtime_registry_test --features runtime --timeout 120

mcpp writes compile_commands.json under target/<triple>/<fingerprint>/. mcpp build --configure-only produces a database without compiling the project. Set MCPP_COMPILE_COMMANDS=compile_commands.json for a run to copy it to the checkout root. The C++ standard is a property of the whole module graph and comes from the root package manifest. The integration package selects C++26 and accepts the same debug and release profiles as the C++23 root. When preparing a release, update the version in mcpp.toml and src/mcpp.toml alongside VERSION.

Windows and cross-compilation

Select the GNU Windows target on Windows or when cross-compiling from Linux.

mcpp build --target x86_64-windows-gnu --profile release
mcpp build --target x86_64-windows-gnu --features runtime --profile release
mcpp test --target x86_64-windows-gnu --profile release --no-run

On Windows, the managed MinGW bin directory belongs on PATH when running these dynamically linked binaries. The first entry in the generated compilation database records the compiler path. Run mcpp test --target x86_64-windows-gnu --profile release on Windows to execute the tests. The CMake matrix remains the supported route for MSVC and the Vista compatibility option.

Consume the experimental module

Build this example with mcpp run module_example --features modules.

import std;
import threadschedule;
int main()
{
auto answer = pool.submit([] { return 42; });
return answer && answer->get() == 42 ? 0 : 1;
}
Fixed-size thread pool for queued asynchronous work.
auto submit(F &&function, Args &&... args) -> result< std::future< detail::bind_result_t< F, Args... > > >
Submit work and receive a future for its result.
Value type for pool worker count.

For a separate mcpp package, add a Git dependency pinned to a ThreadSchedule release tag. Put the application above in src/main.cpp and run mcpp run.

[package]
name = "my-app"
version = "0.1.0"
standard = "c++23"
[toolchain]
default = "gcc@16.2.0"
[dependencies]
threadschedule = { git = "https://github.com/Katze719/ThreadSchedule.git", tag = "v4.1.0", features = ["modules"] }

To develop against a local checkout, use path = "../ThreadSchedule" in place of git and tag.

For header-based use, omit features = ["modules"] and include <threadschedule/threadschedule.hpp>. To use the optional registry runtime, request the runtime dependency feature and define THREADSCHEDULE_RUNTIME under [build] in any consuming package that includes ThreadSchedule headers. Use a common dynamic C++ runtime across all binaries that share registry state.

import threadschedule exposes the portable API from the core umbrella, including expected, thread, jthread where available, configuration, the registry, and both pool types. One interface unit includes the existing headers in the global module fragment and exports selected names using declarations. The declarations keep their original ownership and linkage. Advanced features are available through their existing headers. Macros still come from headers and compile flags.

The module interface and the implementation use ordinary standard-library and platform headers so they see the feature-test macros and native declarations. Module consumers can use import std for standard-library names. The mixed integration passes thread_pool and result<int> across separate import and include translation units, exercises standard-library interoperability, and checks that the registry identity and contents agree. Use the same compiler, standard-library ABI, flags and ThreadSchedule configuration across a mixed build. Rebuild compiler-specific module artifacts when any of those inputs change. CMake and Conan continue to distribute the header and runtime APIs.

Module coverage

Toolchain Configuration
Linux x86-64, GCC/libstdc++ 16.2.0 C++23 module example, and C++26 mixed header and module consumers with and without the shared runtime
MinGW-w64/GCC, Windows x86-64 Header consumers. The managed Linux-to-Windows GCC 16.2.0 toolchain fails linking the combined imports with a duplicate libstdc++ _Sp_make_shared_tag::_S_ti()::__tag symbol from libstdc++exp.
MSVC and other compiler or library combinations Experimental module coverage is limited to the configurations above. See the header compatibility matrix for supported consumers.

Run the C++26 integration from its package directory.

cd integration_tests/modules
mcpp test
mcpp test --profile release --features runtime

Run the thread benchmarks

mcpp run thread_benchmarks --features benchmarks --profile release -- --output thread-timing.json
mcpp run thread_allocation_benchmarks --features benchmarks --profile release -- --output thread-allocations.json

The native targets reuse the two standalone thread runners and pin nlohmann.json. Save the compilation database with the results for the exact mcpp flags. Use the CMake benchmark targets for the Google Benchmark suite, which has no Google Benchmark package in the configured mcpp index. The allocation runner deliberately replaces global new and delete, which the mcpp ELF symbol checker reports.

Migration measurements

These are local results from Linux x86-64 on a Ryzen 5 5600X, using mcpp 2026.11.22.1, CMake 4.3.0, and the same managed GCC/libstdc++ 16.2.0 with C++23, -O2, -DNDEBUG, and one build worker. Each median uses three fresh projects containing the same pool example. The clean CMake build starts after configuration. The clean mcpp build includes planning and uses a cached std BMI while rebuilding the ThreadSchedule BMI. The incremental edit changes a value returned by the application's task. Compile-only times use the same compiler commands with the required BMIs already built.

Consumer build Clean Incremental No-op Compile application TU Executable size
CMake, headers 4.834 s 4.765 s 0.010 s 156,456 bytes
mcpp, headers 5.218 s 5.123 s 0.078 s 4.582 s 156,456 bytes
mcpp, modules 7.795 s 3.038 s 0.079 s 2.731 s 156,616 bytes

The standalone thread runners used the same compiler, C++ standard, optimization level, and JSON library version. With 100 warmups and 1,000 startup samples per case, median threadschedule::thread construction was 19.17 µs with CMake and 19.62 µs with mcpp, and construction with naming was 32.49 µs and 32.81 µs. A single run per build provides a snapshot of startup cost. The allocation counts and requested bytes matched in every sample and scenario. Direct construction used 2 allocations and 152 bytes without a name, and 3 allocations and 288 bytes with a name. The measured object sizes and alignments also matched.