{"id":48524574,"url":"https://github.com/katze719/threadschedule","last_synced_at":"2026-04-07T22:01:05.494Z","repository":{"id":310725046,"uuid":"1040981005","full_name":"Katze719/ThreadSchedule","owner":"Katze719","description":"A modern C++ library for advanced thread management on Linux and Windows. ","archived":false,"fork":false,"pushed_at":"2026-03-31T20:04:03.000Z","size":364,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-31T21:34:16.471Z","etag":null,"topics":["cpp-modules","cpp17","cpp20","cpp23","cpp26","multithreading"],"latest_commit_sha":null,"homepage":"https://katze719.github.io/ThreadSchedule/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Katze719.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-19T19:52:55.000Z","updated_at":"2026-03-31T20:03:25.000Z","dependencies_parsed_at":"2026-04-07T22:00:34.388Z","dependency_job_id":null,"html_url":"https://github.com/Katze719/ThreadSchedule","commit_stats":null,"previous_names":["katze719/threadschedule"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/Katze719/ThreadSchedule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katze719%2FThreadSchedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katze719%2FThreadSchedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katze719%2FThreadSchedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katze719%2FThreadSchedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Katze719","download_url":"https://codeload.github.com/Katze719/ThreadSchedule/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katze719%2FThreadSchedule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31530647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp-modules","cpp17","cpp20","cpp23","cpp26","multithreading"],"created_at":"2026-04-07T22:00:25.641Z","updated_at":"2026-04-07T22:01:05.482Z","avatar_url":"https://github.com/Katze719.png","language":"C++","readme":"# ThreadSchedule\n\n[![Tests](https://github.com/Katze719/ThreadSchedule/actions/workflows/tests.yml/badge.svg)](https://github.com/Katze719/ThreadSchedule/actions/workflows/tests.yml)\n[![Integration](https://github.com/Katze719/ThreadSchedule/actions/workflows/integration.yml/badge.svg)](https://github.com/Katze719/ThreadSchedule/actions/workflows/integration.yml)\n[![Registry Integration](https://github.com/Katze719/ThreadSchedule/actions/workflows/registry-integration.yml/badge.svg)](https://github.com/Katze719/ThreadSchedule/actions/workflows/registry-integration.yml)\n[![Runtime Tests](https://github.com/Katze719/ThreadSchedule/actions/workflows/runtime-tests.yml/badge.svg)](https://github.com/Katze719/ThreadSchedule/actions/workflows/runtime-tests.yml)\n[![Documentation](https://github.com/Katze719/ThreadSchedule/actions/workflows/documentation.yml/badge.svg)](https://github.com/Katze719/ThreadSchedule/actions/workflows/documentation.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA modern C++ library for advanced thread management on Linux and Windows.\nThreadSchedule provides enhanced wrappers for `std::thread`, `std::jthread`, and\n`pthread` with extended functionality including thread naming, priority\nmanagement, CPU affinity, and high-performance thread pools.\n\nAvailable as **header-only**, as a **C++20 module** (`import threadschedule;`),\nor with optional **shared runtime** for multi-DSO applications.\n\n## Key Features\n\n- **Modern C++**: Full C++17, C++20, C++23, and C++26 support with automatic\n  feature detection and optimization\n- **C++20 Modules**: Optional `import threadschedule;` support (C++20+)\n- **Header-Only or Shared Runtime**: Choose based on your needs\n- **Enhanced Wrappers**: Extend `std::thread`, `std::jthread`, and `pthread`\n  with powerful features\n- **Non-owning Views**: Zero-overhead views to configure existing threads or\n  find by name (Linux)\n- **Thread Naming**: Human-readable thread names for debugging\n- **Priority \u0026 Scheduling**: Fine-grained control over thread priorities and\n  scheduling policies\n- **CPU Affinity**: Pin threads to specific CPU cores\n- **Global Control Registry**: Process-wide registry to list and control running\n  threads (affinity, priority, name)\n- **Profiles**: High-level presets for priority/policy/affinity\n- **NUMA-aware Topology Helpers**: Easy affinity builders across nodes\n- **Chaos Testing**: RAII controller to perturb affinity/priority for validation\n- **C++20 Coroutines**: `task\u003cT\u003e`, `generator\u003cT\u003e`, and `sync_wait` out of the\n  box - no boilerplate promise types needed\n- **High-Performance Pools**: Work-stealing pool, `post()` / `try_post()`, and\n  optional `LightweightPool` for fire-and-forget workloads with minimal overhead\n- **Scheduled Tasks**: Run tasks at specific times, after delays, or\n  periodically\n- **Error Handling**: Comprehensive exception handling with error callbacks and\n  context\n- **Performance Metrics**: Built-in statistics and monitoring\n- **RAII \u0026 Exception Safety**: Automatic resource management\n- **Multiple Integration Methods**: CMake, CPM, Conan, FetchContent\n\n## What's new in v2.0\n\nVersion 2.0 focuses on **lower-overhead submission**, **more control over\nshutdown and tuning**, and **better ergonomics** for modern C++ (ranges,\ncoroutines, `std::stop_token`). Highlights:\n\n| Area                        | What changed                                                                                                                                                                                                                                                         |\n| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **Lightweight pool**        | `LightweightPoolT\u003cTaskSize\u003e` / `LightweightPool` - fire-and-forget only, configurable SBO buffer (default 64 B), no futures or stats. Workers are still `ThreadWrapper` (name, affinity, policy). Ideal for maximum throughput when you do not need a return value. |\n| **`post()` / `try_post()`** | On `HighPerformancePool`, `ThreadPool` / `FastThreadPool`, and `GlobalPool` - same queue path as `submit()` but skips `packaged_task` / `future` overhead.                                                                                                          |\n| **Non-throwing submit**     | `try_submit()` returns `expected\u003cfuture\u003cR\u003e, error_code\u003e`; `try_submit_batch()` returns `expected\u003cvector\u003cfuture\u003cvoid\u003e\u003e, error_code\u003e` instead of throwing on shutdown.                                                                                                  |\n| **Scheduled dispatch**      | `ScheduledThreadPoolT` dispatches with `post()` internally. Alias `ScheduledLightweightPool` uses `LightweightPool` as the backend.                                                                                                                                  |\n| **Shutdown**                | `ShutdownPolicy::drain` (default) vs `drop_pending`; `shutdown_for(timeout)` for a timed drain.                                                                                                                                                                      |\n| **Parallel loops**          | Chunked `parallel_for_each` on all pool types (shared helper across single-queue and work-stealing pools).                                                                                                                                                           |\n| **Tuning**                  | `PollingWait\u003cIntervalMs\u003e` for `FastThreadPool`, configurable work-stealing deque capacity on `HighPerformancePool`, `GlobalPool::init(n)` before first use.                                                                                                          |\n| **C++20**                   | Ranges overloads for batch submit and `parallel_for_each`; `submit`/`try_submit` with `std::stop_token` (cooperative skip).                                                                                                                                          |\n| **Futures**                 | `when_all`, `when_any`, `when_all_settled` in `futures.hpp`.                                                                                                                                                                                                         |\n| **Coroutines**              | `schedule_on{pool}`, `pool_executor`, `run_on(pool, coro_fn)` for pool-aware `task`.                                                                                                                                                                                 |\n| **Observability**           | Optional auto-registration of pool workers in the thread registry; per-task `set_on_task_start` / `set_on_task_end` hooks.                                                                                                                                           |\n| **Errors**                  | `ErrorHandler` callbacks get stable IDs; `remove_callback(id)` / `has_callback(id)`.                                                                                                                                                                                 |\n\nSee \u003ca href=\"CHANGELOG.md\"\u003eCHANGELOG.md\u003c/a\u003e for the full list, including breaking changes\nwhen upgrading from v1.x.\n\n**Upgrading from v1.x:** [Migration guide (v2.0)](docs/MIGRATION_V2.md)\n\n## Documentation\n\n- **[Migrating to v2.0](docs/MIGRATION_V2.md)** - Breaking changes, renames, and\n  recommended follow-ups from v1.x\n- **[Integration Guide](docs/INTEGRATION.md)** - CMake, Conan, FetchContent,\n  system installation\n- **[Thread Registry Guide](docs/REGISTRY.md)** - Process-wide thread control\n  and multi-DSO patterns\n- **[Scheduled Tasks Guide](docs/SCHEDULED_TASKS.md)** - Timer and periodic task\n  scheduling\n- **[Error Handling Guide](docs/ERROR_HANDLING.md)** - Exception handling with\n  callbacks\n- **[CMake Reference](docs/CMAKE_REFERENCE.md)** - Build options, targets, and\n  troubleshooting\n- **[Profiles](docs/PROFILES.md)** - High-level presets for\n  priority/policy/affinity\n- **[Topology \u0026 NUMA](docs/TOPOLOGY_NUMA.md)** - NUMA-aware affinity builders\n- **[Chaos Testing](docs/CHAOS_TESTING.md)** - RAII controller to perturb\n  affinity/priority for validation\n- **[Coroutines](docs/COROUTINES.md)** - C++20 `task\u003cT\u003e`, `generator\u003cT\u003e`, and\n  `sync_wait`\n- **Feature Roadmap** - Current features and future plans (see below)\n\n## Platform Support\n\nThreadSchedule is designed to work on any platform with a C++17 (or newer)\ncompiler and standard threading support. The library is **continuously tested**\non:\n\n| Platform            | Compiler           | C++17 | C++20 | C++23 | C++26 |\n| ------------------- | ------------------ | :---: | :---: | :---: | :---: |\n| **Linux (x86_64)**  |                    |       |       |       |       |\n| Ubuntu 22.04        | GCC 11             |  yes   |  yes   |  yes   |   -   |\n| Ubuntu 22.04        | GCC 12             |   -   |  yes   |   -   |   -   |\n| Ubuntu 22.04        | Clang 14           |  yes   |  yes   |  yes   |   -   |\n| Ubuntu 22.04        | Clang 15           |   -   |  yes   |  yes   |   -   |\n| Ubuntu 24.04        | GCC 13             |  yes   |  yes   |  yes   |   -   |\n| Ubuntu 24.04        | GCC 14             |  yes   |  yes   |  yes   |  yes   |\n| Ubuntu 24.04        | GCC 15             |   -   |  yes   |  yes   |  yes   |\n| Ubuntu 24.04        | Clang 16           |  yes   |  yes   |   -   |   -   |\n| Ubuntu 24.04        | Clang 18           |  yes   |  yes   |   -   |   -   |\n| Ubuntu 24.04        | Clang 19           |   -   |  yes   |  yes   |  yes   |\n| Ubuntu 24.04        | Clang 21           |   -   |  yes   |  yes   |  yes   |\n| **Linux (ARM64)**   |                    |       |       |       |       |\n| Ubuntu 24.04 ARM64  | GCC 13 (system)    |  yes   |  yes   |  yes   |   -   |\n| Ubuntu 24.04 ARM64  | GCC 14             |   -   |  yes   |  yes   |  yes   |\n| **Windows**         |                    |       |       |       |       |\n| Windows Server 2022 | MSVC 2022          |  yes   |  yes   |  yes   |   -   |\n| Windows Server 2022 | MinGW-w64 (GCC 15) |  yes   |  yes   |  yes   |   -   |\n| Windows Server 2025 | MSVC 2022          |  yes   |  yes   |  yes   |   -   |\n| Windows Server 2025 | MinGW-w64 (GCC 15) |  yes   |  yes   |  yes   |   -   |\n\n**Additional platforms:** ThreadSchedule should work on other platforms (macOS,\nFreeBSD, other Linux distributions) with standard C++17+ compilers, but these\nare not regularly tested in CI.\n\n\u003e **C++23**: GCC 12's libstdc++ lacks monadic `std::expected` operations\n\u003e (`and_then`, `transform`, ...). Clang 16/18 on Ubuntu 24.04 use GCC 14's\n\u003e libstdc++ headers which expose `std::expected` incorrectly to those Clang\n\u003e versions. These combinations are therefore only tested up to C++20.\n\u003e\n\u003e **C++26**: Requires GCC 14+ or Clang 19+. MSVC does not yet expose\n\u003e `cxx_std_26` to CMake; C++26 on Windows is not tested.\n\u003e\n\u003e **GCC 15**: Installed via `ppa:ubuntu-toolchain-r/test` on Ubuntu 24.04.\n\u003e\n\u003e **Clang 21**: Installed via the official LLVM apt repository (`apt.llvm.org`)\n\u003e on Ubuntu 24.04.\n\u003e\n\u003e **Windows ARM64**: Not currently covered by GitHub-hosted runners, requires\n\u003e self-hosted runner for testing.\n\u003e\n\u003e **MinGW**: MinGW-w64 (MSYS2) ships GCC 15 and provides full Windows API\n\u003e support including thread naming (Windows 10+).\n\n## Quick Start\n\n### Installation\n\nAdd to your CMakeLists.txt using\n[CPM.cmake](https://github.com/cpm-cmake/CPM.cmake):\n\n```cmake\ninclude(${CMAKE_BINARY_DIR}/cmake/CPM.cmake)\n\nCPMAddPackage(\n    NAME ThreadSchedule\n    GITHUB_REPOSITORY Katze719/ThreadSchedule\n    GIT_TAG main  # or specific version tag\n    OPTIONS \"THREADSCHEDULE_BUILD_EXAMPLES OFF\" \"THREADSCHEDULE_BUILD_TESTS OFF\"\n)\n\nadd_executable(your_app src/main.cpp)\ntarget_link_libraries(your_app PRIVATE ThreadSchedule::ThreadSchedule)\n```\n\n**Other integration methods:** See [docs/INTEGRATION.md](docs/INTEGRATION.md)\nfor FetchContent, Conan, system installation, and shared runtime option.\n\n### C++20 Module Usage\n\nThreadSchedule can also be consumed as a C++20 module (requires CMake 3.28+ and\nNinja or Visual Studio 17.4+):\n\n```cmake\n# In your CMakeLists.txt\nset(CMAKE_CXX_STANDARD 20)\n\nCPMAddPackage(\n    NAME ThreadSchedule\n    GITHUB_REPOSITORY Katze719/ThreadSchedule\n    GIT_TAG main\n    OPTIONS \"THREADSCHEDULE_MODULE ON\"\n)\n\nadd_executable(your_app src/main.cpp)\ntarget_link_libraries(your_app PRIVATE ThreadSchedule::Module)\n```\n\n```cpp\n// src/main.cpp\nimport threadschedule;\n\nint main() {\n    ts::HighPerformancePool pool(4);\n    auto future = pool.submit([]() { return 42; });\n    return future.get() != 42;\n}\n```\n\n### Basic Usage\n\n```cpp\n#include \u003cthreadschedule/threadschedule.hpp\u003e\n\nusing namespace threadschedule;\n\nint main() {\n    // Enhanced thread with configuration\n    ThreadWrapper worker([]() {\n        std::cout \u003c\u003c \"Worker running!\" \u003c\u003c std::endl;\n    });\n    worker.set_name(\"my_worker\");\n    worker.set_priority(ThreadPriority::normal());\n    \n    // High-performance thread pool\n    HighPerformancePool pool(4);\n    pool.configure_threads(\"worker\");\n    pool.distribute_across_cpus();\n    \n    auto future = pool.submit([]() { return 42; });\n    std::cout \u003c\u003c \"Result: \" \u003c\u003c future.get() \u003c\u003c std::endl;\n\n    // Fire-and-forget (no future): post() on any pool, or LightweightPool\n    pool.post([]() { /* work */ });\n    LightweightPool lite(4);\n    lite.configure_threads(\"lite\");\n    lite.post([]() { /* minimal overhead */ });\n    \n    // Scheduled tasks (uses ThreadPool by default)\n    ScheduledThreadPool scheduler(4);\n    auto handle = scheduler.schedule_periodic(std::chrono::seconds(5), []() {\n        std::cout \u003c\u003c \"Periodic task executed!\" \u003c\u003c std::endl;\n    });\n    \n    // Or use high-performance pool for frequent tasks\n    ScheduledHighPerformancePool scheduler_hp(4);\n    auto handle_hp = scheduler_hp.schedule_periodic(std::chrono::milliseconds(100), []() {\n        std::cout \u003c\u003c \"Frequent task!\" \u003c\u003c std::endl;\n    });\n\n    // v2: ScheduledLightweightPool - same API, LightweightPool backend (post-based dispatch)\n    \n    // Error handling\n    HighPerformancePoolWithErrors pool_safe(4);\n    pool_safe.add_error_callback([](const TaskError\u0026 error) {\n        std::cerr \u003c\u003c \"Task error: \" \u003c\u003c error.what() \u003c\u003c std::endl;\n    });\n    \n    return 0;\n}\n```\n\n### Non-owning Thread Views\n\nOperate on existing threads without owning their lifetime.\n\n```cpp\n#include \u003cthreadschedule/threadschedule.hpp\u003e\nusing namespace threadschedule;\n\nstd::thread t([]{ /* work */ });\n\n// Configure existing std::thread\nThreadWrapperView v(t);\nv.set_name(\"worker_0\");\nv.set_affinity(ThreadAffinity({0}));\nv.join(); // joins the underlying t\n```\n\n#### Using thread views with APIs expecting std::thread/std::jthread references\n\n- Views do not own threads. Use `.get()` to pass a reference to APIs that expect\n  `std::thread\u0026` or (C++20) `std::jthread\u0026`.\n- Ownership stays with the original `std::thread`/`std::jthread` object.\n\n```cpp\nvoid configure(std::thread\u0026 t);\n\nstd::thread t([]{ /* work */ });\nThreadWrapperView v(t);\nconfigure(v.get()); // non-owning reference\n```\n\nYou can also pass threads directly to APIs that take views; the view is created\nimplicitly (non-owning):\n\n```cpp\nvoid operate(threadschedule::ThreadWrapperView v);\n\nstd::thread t2([]{});\noperate(t2); // implicit, non-owning\n```\n\n`std::jthread` (C++20):\n\n```cpp\nstd::jthread jt([](std::stop_token st){ /* work */ });\nJThreadWrapperView jv(jt);\njv.set_name(\"jworker\");\njv.request_stop();\njv.join();\n```\n\n### Global Thread Registry\n\nOpt-in registered threads with process-wide control, without imposing overhead\non normal wrappers.\n\n```cpp\n#include \u003cthreadschedule/registered_threads.hpp\u003e\n#include \u003cthreadschedule/thread_registry.hpp\u003e\nusing namespace threadschedule;\n\nint main() {\n    // Opt-in registration via *Reg wrapper\n    ThreadWrapperReg t(\"worker-1\", \"io\", [] {\n        // ... work ...\n    });\n\n    // Chainable query API - direct filter and apply operations\n    registry()\n        .filter([](const RegisteredThreadInfo\u0026 e){ return e.componentTag == \"io\"; })\n        .for_each([\u0026](const RegisteredThreadInfo\u0026 e){\n            (void)registry().set_name(e.tid, std::string(\"io-\")+e.name);\n            (void)registry().set_priority(e.tid, ThreadPriority{0});\n        });\n    \n    // Count threads by tag\n    auto io_count = registry()\n        .filter([](const RegisteredThreadInfo\u0026 e){ return e.componentTag == \"io\"; })\n        .count();\n    \n    // Check if any IO threads exist\n    bool has_io = registry().any([](const RegisteredThreadInfo\u0026 e){ return e.componentTag == \"io\"; });\n    \n    // Find specific thread\n    auto found = registry().find_if([](const RegisteredThreadInfo\u0026 e){ return e.name == \"worker-1\"; });\n    \n    // Map to extract TIDs\n    auto tids = registry().filter(...).map([](auto\u0026 e) { return e.tid; });\n\n    t.join();\n}\n```\n\n**For multi-DSO applications:** Use the shared runtime option\n(`THREADSCHEDULE_RUNTIME=ON`) to ensure a single process-wide registry. See\n[docs/REGISTRY.md](docs/REGISTRY.md) for detailed patterns.\n\nNotes:\n\n- Normal wrappers (`ThreadWrapper`, `JThreadWrapper`, `PThreadWrapper`) remain\n  zero-overhead.\n- The registry **requires control blocks** for all operations. Threads must be\n  registered with control blocks to be controllable via the registry.\n- Use `*Reg` wrappers (e.g., `ThreadWrapperReg`) or `AutoRegisterCurrentThread`\n  for automatic control block creation and registration.\n\nFind by name (Linux):\n\n```cpp\nThreadByNameView by_name(\"th_1\");\nif (by_name.found()) {\n    by_name.set_name(\"new_name\");\n    ThreadAffinity one_core; one_core.add_cpu(0);\n    by_name.set_affinity(one_core);\n}\n```\n\n### Error handling with expected\n\nThreadSchedule uses `threadschedule::expected\u003cT, std::error_code\u003e` (and\n`expected\u003cvoid, std::error_code\u003e`). When available, this aliases to\n`std::expected`, otherwise, a compatible fallback based on\n[P0323R3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0323r3.pdf)\nis used.\n\n\u003e Note: when building with `-fno-exceptions`, behavior is not\n\u003e standard-conforming because `value()`/`operator*` cannot throw\n\u003e `bad_expected_access` on error (exceptions are disabled). In that mode, always\n\u003e check `has_value()` or use `value_or()` before accessing the value.\n\nRecommended usage:\n\n```cpp\nauto r = worker.set_name(\"my_worker\");\nif (!r) {\n    // Inspect r.error() (std::error_code)\n}\n\nauto value = pool.submit([]{ return 42; }); // standard future-based API remains unchanged\n```\n\n### Coroutines (C++20)\n\nLazy coroutine primitives - no boilerplate promise types required.\n\n```cpp\n#include \u003cthreadschedule/threadschedule.hpp\u003e\nusing namespace threadschedule;\n\n// Lazy single-value coroutine\ntask\u003cint\u003e compute(int x) {\n    co_return x * 2;\n}\n\ntask\u003cint\u003e pipeline() {\n    int a = co_await compute(21);  // lazy - starts here\n    co_return a;                   // 42\n}\n\nint main() {\n    // Blocking bridge for synchronous code\n    int result = sync_wait(pipeline());\n\n    // Lazy sequence coroutine\n    auto fib = []() -\u003e generator\u003cint\u003e {\n        int a = 0, b = 1;\n        while (true) {\n            co_yield a;\n            auto tmp = a; a = b; b = tmp + b;\n        }\n    };\n\n    for (int v : fib()) {\n        if (v \u003e 1000) break;\n        std::cout \u003c\u003c v \u003c\u003c \"\\n\";\n    }\n}\n```\n\n**For more details:** See the [Coroutines Guide](docs/COROUTINES.md).\n\n## API Overview\n\n### Thread Wrappers\n\n| Class            | Description                                                   | Available On   |\n| ---------------- | ------------------------------------------------------------- | -------------- |\n| `ThreadWrapper`  | Enhanced `std::thread` with naming, priority, affinity        | Linux, Windows |\n| `JThreadWrapper` | Enhanced `std::jthread` with cooperative cancellation (C++20) | Linux, Windows |\n| `PThreadWrapper` | Modern C++ interface for POSIX threads                        | Linux only     |\n\n#### Passing wrappers into APIs expecting std::thread/std::jthread\n\n- `std::thread` and `std::jthread` are move-only. When an API expects\n  `std::thread\u0026\u0026` or `std::jthread\u0026\u0026`, pass the underlying thread via\n  `release()` from the wrapper.\n- Avoid relying on implicit conversions; `release()` clearly transfers ownership\n  and prevents accidental selection of the functor constructor of `std::thread`.\n\n```cpp\nvoid accept_std_thread(std::thread\u0026\u0026 t);\n\nThreadWrapper w([]{ /* work */ });\naccept_std_thread(w.release()); // move ownership of the underlying std::thread\n```\n\n- Conversely, you can construct wrappers from rvalue threads:\n\n```cpp\nvoid take_wrapper(ThreadWrapper w);\n\nstd::thread make_thread();\ntake_wrapper(make_thread());       // implicit move into ThreadWrapper\n\nstd::thread t([]{});\ntake_wrapper(std::move(t));        // explicit move into ThreadWrapper\n```\n\n### Thread Views (non-owning)\n\nZero-overhead helpers to operate on existing threads without taking ownership.\n\n| Class                | Description                                  | Available On   |\n| -------------------- | -------------------------------------------- | -------------- |\n| `ThreadWrapperView`  | View over an existing `std::thread`          | Linux, Windows |\n| `JThreadWrapperView` | View over an existing `std::jthread` (C++20) | Linux, Windows |\n| `ThreadByNameView`   | Locate and control a thread by its name      | Linux only     |\n\n### Thread Pools\n\n| Class                 | Use Case                                      | Notes                                                                  |\n| --------------------- | --------------------------------------------- | ---------------------------------------------------------------------- |\n| `ThreadPool`          | Single shared queue, blocks while idle        | `submit`, `try_submit`, `post`, batches, `parallel_for_each`           |\n| `FastThreadPool`      | Same as `ThreadPool` with polling wait policy | Tunable via `PollingWait\u003cIntervalMs\u003e`                                  |\n| `HighPerformancePool` | Work-stealing + overflow queue                | Highest throughput for large batches; tunable deque capacity           |\n| `LightweightPool`     | Fire-and-forget only, SBO tasks               | No futures; use `post` / `post_batch`. Alias of `LightweightPoolT\u003c64\u003e` |\n\nAll of the above support `shutdown(ShutdownPolicy)` and `shutdown_for(timeout)`\nwhere applicable. Use **`post()`** when you do not need a `std::future` (lower\noverhead than `submit()`).\n\n### Configuration\n\n```cpp\n// Scheduling policies\nSchedulingPolicy::OTHER    // Standard time-sharing\nSchedulingPolicy::FIFO     // Real-time FIFO\nSchedulingPolicy::RR       // Real-time round-robin\nSchedulingPolicy::BATCH    // Batch processing\nSchedulingPolicy::IDLE     // Low priority background\n\n// Priority management\nThreadPriority::lowest()   // Minimum priority\nThreadPriority::normal()   // Default priority\nThreadPriority::highest()  // Maximum priority\nThreadPriority(value)      // Custom priority\n\n// CPU affinity\nThreadAffinity affinity({0, 1, 2});  // Pin to CPUs 0, 1, 2\nworker.set_affinity(affinity);\n```\n\n**For more details:** See the [Integration Guide](docs/INTEGRATION.md),\n[Registry Guide](docs/REGISTRY.md), and\n[CMake Reference](docs/CMAKE_REFERENCE.md) linked at the top of this README.\n\n### Benchmark Results\n\nPerformance varies by system configuration, workload characteristics, and task\ncomplexity. See [benchmarks/](benchmarks/) for detailed performance analysis,\nreal-world scenario testing, and optimization recommendations.\n\n## Platform-Specific Features\n\n### Linux\n\n- Full `pthread` API support\n- Real-time scheduling policies (FIFO, RR, DEADLINE)\n- CPU affinity and NUMA control\n- Nice values for process priority\n\n### Windows\n\n- Thread naming (Windows 10 1607+)\n- Thread priority classes\n- CPU affinity masking\n- Process priority control\n\n**Note**: `PThreadWrapper` is Linux-only. Use `ThreadWrapper` or\n`JThreadWrapper` for cross-platform code.\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes with clear messages\n4. Push to your branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file\nfor details.\n\n## Acknowledgments\n\n- POSIX threads documentation\n- Modern C++ threading best practices\n- Linux kernel scheduling documentation\n- C++20/23/26 concurrency improvements\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatze719%2Fthreadschedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatze719%2Fthreadschedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatze719%2Fthreadschedule/lists"}