ThreadSchedule 4.1.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::detail::inline_pool_backend Class Reference

A pool that executes every task inline on the calling thread. More...

#include <inline_pool_backend.hpp>

Public Member Functions

 inline_pool_backend (size_t=0)
template<typename F, typename... Args>
auto submit (F &&f, Args &&... args) -> std::future< bind_result_t< F, Args... > >
template<typename F, typename... Args>
auto try_submit (F &&f, Args &&... args) -> expected< std::future< bind_result_t< F, Args... > >, std::error_code >
template<typename F, typename... Args>
void post (F &&f, Args &&... args)
template<typename F, typename... Args>
auto try_post (F &&f, Args &&... args) -> expected< void, std::error_code >
template<typename Iterator>
auto try_submit_batch (Iterator begin, Iterator end) -> expected< std::vector< std::future< void > >, std::error_code >
template<typename Iterator>
auto submit_batch (Iterator begin, Iterator end) -> std::vector< std::future< void > >
template<typename Iterator, typename F>
void parallel_for_each (Iterator begin, Iterator end, F &&func)
auto size () const noexcept -> size_t
auto pending_tasks () const noexcept -> size_t
void wait_for_tasks ()
void shutdown (shutdown_policy_backend=shutdown_policy_backend::drain)

Detailed Description

A pool that executes every task inline on the calling thread.

Useful for deterministic unit testing: tasks run synchronously in submission order with no concurrency, making results fully reproducible and debuggable.

API compatibility
inline_pool_backend provides the same submit/try_submit/post/try_post/ submit_batch/parallel_for_each surface as thread_pool_backend. The returned futures are always already fulfilled when submit() returns.
Limitations
  • size() always returns 0 (no worker threads).
  • shutdown() and wait_for_tasks() are no-ops.
  • There is no concurrency; tasks that block or deadlock will block the submitting thread.

Definition at line 45 of file inline_pool_backend.hpp.

Constructor & Destructor Documentation

◆ inline_pool_backend()

threadschedule::detail::inline_pool_backend::inline_pool_backend ( size_t = 0)
inlineexplicit

Definition at line 48 of file inline_pool_backend.hpp.

Member Function Documentation

◆ parallel_for_each()

template<typename Iterator, typename F>
void threadschedule::detail::inline_pool_backend::parallel_for_each ( Iterator begin,
Iterator end,
F && func )
inline

◆ pending_tasks()

auto threadschedule::detail::inline_pool_backend::pending_tasks ( ) const->size_t
inlinenodiscardnoexcept

Definition at line 169 of file inline_pool_backend.hpp.

◆ post()

template<typename F, typename... Args>
void threadschedule::detail::inline_pool_backend::post ( F && f,
Args &&... args )
inline

Definition at line 92 of file inline_pool_backend.hpp.

References try_post().

◆ shutdown()

void threadschedule::detail::inline_pool_backend::shutdown ( shutdown_policy_backend = shutdown_policy_backend::drain)
inline

Definition at line 179 of file inline_pool_backend.hpp.

References threadschedule::detail::drain.

◆ size()

auto threadschedule::detail::inline_pool_backend::size ( ) const->size_t
inlinenodiscardnoexcept

Definition at line 164 of file inline_pool_backend.hpp.

◆ submit()

template<typename F, typename... Args>
auto threadschedule::detail::inline_pool_backend::submit ( F && f,
Args &&... args )->std::future< bind_result_t< F, Args... > >
inline

Definition at line 52 of file inline_pool_backend.hpp.

References try_submit().

◆ submit_batch()

template<typename Iterator>
auto threadschedule::detail::inline_pool_backend::submit_batch ( Iterator begin,
Iterator end )->std::vector< std::future< void > >
inline

Definition at line 143 of file inline_pool_backend.hpp.

References try_submit_batch().

◆ try_post()

template<typename F, typename... Args>
auto threadschedule::detail::inline_pool_backend::try_post ( F && f,
Args &&... args )->expected< void, std::error_code >
inline

Definition at line 101 of file inline_pool_backend.hpp.

References threadschedule::detail::bind_args(), and threadschedule::unexpected().

Referenced by post().

◆ try_submit()

template<typename F, typename... Args>
auto threadschedule::detail::inline_pool_backend::try_submit ( F && f,
Args &&... args )->expected< std::future< bind_result_t< F, Args... > >, std::error_code >
inline

Definition at line 62 of file inline_pool_backend.hpp.

References threadschedule::detail::bind_args(), and threadschedule::unexpected().

Referenced by submit().

◆ try_submit_batch()

template<typename Iterator>
auto threadschedule::detail::inline_pool_backend::try_submit_batch ( Iterator begin,
Iterator end )->expected< std::vector< std::future< void > >, std::error_code >
inline

Definition at line 118 of file inline_pool_backend.hpp.

References threadschedule::unexpected().

Referenced by submit_batch().

◆ wait_for_tasks()

void threadschedule::detail::inline_pool_backend::wait_for_tasks ( )
inline

Definition at line 175 of file inline_pool_backend.hpp.


The documentation for this class was generated from the following file: