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

Executor abstraction — IExecutor (virtual), the Executor concept (duck-typed), and three concrete executors: InlineExecutor (runs on the calling thread), SingleThreadExecutor (owns a tiny thread pool of size 1), and ExecutorRef<Exec> (adapts a concept-conforming executor to IExecutor). More...

#include <threadman/display.hpp>
#include <threadman/log.hpp>
#include <commons/display_info.hpp>
#include <concepts>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
Include dependency graph for executor.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  threadman::IExecutor
 Virtual interface for "anything that can run a `std::function<void()>`". More...
 
class  threadman::InlineExecutor
 Runs task() synchronously on the calling thread. More...
 
class  threadman::ExecutorRef< Exec >
 Wraps any Executor-conforming type behind the virtual IExecutor interface, so functions that take IExecutor& accept it. More...
 

Namespaces

namespace  threadman
 
namespace  threadman::detail
 

Concepts

concept  threadman::Executor
 Duck-typed alternative to IExecutor for templated code that wants to avoid a virtual call.
 

Functions

void threadman::detail::execute_on (IExecutor &exec, std::function< void()> task)
 Dispatch helper used by Future::then / SharedFuture::then.
 
template<class Exec >
requires (Executor<Exec> && !std::is_same_v<Exec, IExecutor>)
void threadman::detail::execute_on (Exec &exec, std::function< void()> task)
 

Detailed Description

Executor abstraction — IExecutor (virtual), the Executor concept (duck-typed), and three concrete executors: InlineExecutor (runs on the calling thread), SingleThreadExecutor (owns a tiny thread pool of size 1), and ExecutorRef<Exec> (adapts a concept-conforming executor to IExecutor).

Used by Future::then / SharedFuture::then to dispatch continuations and by callers that just need to enqueue some work without caring how it runs. ThreadPool itself derives from IExecutor.