stlab 2.3.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
Loading...
Searching...
No Matches
task.hpp File Reference

Move-only callable wrapper for executor scheduling (task<Signature>). More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <exception>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
#include <stlab/config.hpp>

Go to the source code of this file.

Classes

class  stlab::task_< NoExcept, R, Args >
 Type-erased, move-only callable with signature R(Args...) (or noexcept variant). More...
struct  stlab::noexcept_deducer< T, R(Args...)>
struct  stlab::noexcept_deducer< T, R(Args...) noexcept >

Typedefs

template<class F>
using stlab::task
 task_ with noexcept deduced from the function type F (e.g. void() vs void() noexcept).

Detailed Description

Move-only callable wrapper for executor scheduling (task<Signature>).

task<F> type-erases any callable target (function, lambda, std::bind, member pointer, etc.) with a fixed signature. It is similar to std::function but not copyable, which suits move-only and single-shot targets (common in messaging and executor queues). An empty task compares equal to nullptr; invoking it throws std::bad_function_call.

Mutable operator() allows moving arguments through for one invocation. Small targets (function pointers, std::reference_wrapper, std::function) may use small-buffer optimization; larger callables are heap-allocated.