threadman 0.1.0
Header-only C++23 managed threads, dynamic pools, futures, and executors
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
thread_pool.hpp File Reference

threadman::ThreadPool — a dynamic-scaling worker-queue executor. More...

#include <threadman/config.hpp>
#include <threadman/display.hpp>
#include <threadman/exceptions.hpp>
#include <threadman/executor.hpp>
#include <threadman/future.hpp>
#include <threadman/log.hpp>
#include <threadman/metrics.hpp>
#include <threadman/stats.hpp>
#include <threadman/task.hpp>
#include <threadman/thread.hpp>
#include <commons/display_info.hpp>
#include <algorithm>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <cstddef>
#include <cstdint>
#include <deque>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <stdexcept>
#include <stop_token>
#include <string>
#include <thread>
#include <unordered_map>
#include <utility>
#include <vector>
Include dependency graph for thread_pool.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  threadman::ThreadPoolOptions
 
class  threadman::ThreadPool
 
class  threadman::SingleThreadExecutor
 

Namespaces

namespace  threadman
 
namespace  threadman::detail
 

Functions

std::uint64_t threadman::detail::next_pool_id () noexcept
 
std::uint64_t threadman::detail::next_task_id () noexcept
 

Detailed Description

threadman::ThreadPool — a dynamic-scaling worker-queue executor.

The pool starts with min_workers "core" workers that never retire and scales up to at most max_workers "non-core" workers when the queue is backed up. Scaling decisions are driven by the ThreadManager housekeeper which calls scale_tick(now) every scale_check_interval. Non-core workers idle out and retire after idle_timeout. The pool is RAII-safe — its destructor calls shutdown() and joins all workers.

Submission has three flavours:

All submit* variants throw PoolShuttingDownError if the pool isn't running and PoolQueueFullError if a bounded queue is at capacity.