execution 1.0.1
Portable task execution, timers, and process lifecycle
Loading...
Searching...
No Matches
stlab::task_< NoExcept, R, Args > Class Template Reference

Type-erased, move-only callable with signature R(Args...) (or noexcept variant). More...

#include <task.hpp>

Public Types

using concept_t
 Stable vtable describing how to move-construct, destroy, and introspect a task's target, independent of the target's concrete type F. Used to relocate a task's target across an ABI boundary (see relocate()) without depending on F or re-boxing the target.
using invoke_t
 Function used to invoke a task's target, valid for as long as the target is live.
using result_type

Public Member Functions

auto relocation_concept () const noexcept -> const concept_t *
 Returns the vtable needed to relocate, invoke, or destroy this task's target without depending on its concrete type.
auto relocation_invoke () const noexcept -> invoke_t
 Returns the function used to invoke this task's target.
auto relocation_source () noexcept -> void *
 Returns the address of this task's inline model storage.
 task_ (const concept_t *vtable_ptr, invoke_t invoke_fn, void *source) noexcept
 Constructs a task by relocating the target described by (vtable_ptr, invoke_fn) out of source, without depending on the target's concrete type.
constexpr task_ (std::nullptr_t) noexcept
 task_ (const task_ &)=delete
 task_ (const task_ &&)=delete
 task_ (task_ &&x) noexcept
template<class F, std::enable_if_t<!NoExcept||std::is_nothrow_invocable_v< F, Args... >, bool > = true>
 task_ (F &&f)
auto operator= (const task_ &) -> task_ &=delete
auto operator= (task_ &&x) noexcept -> task_ &
auto operator= (std::nullptr_t) noexcept -> task_ &
template<class F>
auto operator= (F &&f) -> std::enable_if_t<!NoExcept||std::is_nothrow_invocable_v< decltype(f), Args... >, task_ & >
void swap (task_ &x) noexcept
 operator bool () const
auto target_type () const noexcept -> const std::type_info &
template<class T>
auto target () -> T *
template<class T>
auto target () const -> const T *
template<class... Brgs>
auto operator() (Brgs &&... brgs) noexcept(NoExcept) -> R

Detailed Description

template<bool NoExcept, class R, class... Args>
class stlab::task_< NoExcept, R, Args >

Type-erased, move-only callable with signature R(Args...) (or noexcept variant).

Mutable operator() supports moving arguments through for single invocations. Compare to nullptr when empty; use target() / target_type() for runtime type queries.

Constructor & Destructor Documentation

◆ task_()

template<bool NoExcept, class R, class... Args>
stlab::task_< NoExcept, R, Args >::task_ ( const concept_t * vtable_ptr,
invoke_t invoke_fn,
void * source )
inlinenoexcept

Constructs a task by relocating the target described by (vtable_ptr, invoke_fn) out of source, without depending on the target's concrete type.

  • Precondition: source is the relocation_source() of a live task sharing the same vtable_ptr/invoke_fn.
  • Postcondition: the target at source is left moved-from; the source task must still be destroyed normally (it is not emptied by this call).

Member Function Documentation

◆ relocation_source()

template<bool NoExcept, class R, class... Args>
auto stlab::task_< NoExcept, R, Args >::relocation_source ( ) -> void *
inlinenodiscardnoexcept

Returns the address of this task's inline model storage.

  • Precondition: valid only until *this is destroyed, reassigned, or moved from.

The documentation for this class was generated from the following file:
  • /home/runner/work/stlab-execution/stlab-execution/include/stlab/concurrency/task.hpp