execution 1.0.1
Portable task execution, timers, and process lifecycle
Loading...
Searching...
No Matches
stlab Namespace Reference

Classes

struct  executor
 Wraps an executor_t for use with operator&. More...
struct  executor_task_pair
 Executor plus callable, produced by executor & f (used by futures and channels). More...
struct  noexcept_deducer
struct  noexcept_deducer< T, R(Args...) noexcept >
struct  noexcept_deducer< T, R(Args...)>
struct  stlab_v2_task_concept
 Versioned operation table used to relocate a task target across the shared executor ABI. More...
struct  stlab_v2_timer_status
 Resource result: code 0 is success, 1 allocation failure, 2 generic-category error, and 3 system-category error. native_error is the category's numeric error value. More...
class  task_
 Type-erased, move-only callable with signature R(Args...) (or noexcept variant). More...

Typedefs

using stlab_v2_task_proc
 Function pointer type submitted through the shared executor ABI.
using executor_t
 Type-erased executor: accepts a void() noexcept task.
using stlab_v2_task_proc
 Invocation operation for a relocated void() noexcept task.
template<class F>
using task
 task_ with noexcept deduced from the function type F (e.g. void() vs void() noexcept).
using pre_exit_handler
 Function type invoked during pre_exit() (must not throw; noexcept with C++17 and later).

Functions

void stlab_v2_default_executor_submit (const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source) noexcept
 Submits one task to the shared default-priority executor.
void stlab_v2_high_executor_submit (const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source) noexcept
 Submits one task to the shared high-priority executor.
void stlab_v2_low_executor_submit (const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source) noexcept
 Submits one task to the shared low-priority executor.
void stlab_v2_notify_default_executor_before_waiting () noexcept
 Notifies the shared default executor that the calling thread is about to wait.
std::int32_t stlab_v2_default_executor_supports_blocking () noexcept
 Returns one when the configured core supports blocking waits, otherwise zero.
template<typename Rep, typename Per = std::ratio<1>>
auto execute_at (std::chrono::duration< Rep, Per > duration, executor_t executor) -> executor_t
 Returns an executor that posts tasks to executor after duration (immediate if zero).
auto execute_at (std::chrono::steady_clock::time_point when, executor_t executor) -> executor_t
template<typename E, typename Rep, typename Per = std::ratio<1>>
auto execute_delayed (std::chrono::duration< Rep, Per > duration, E executor)
 Returns an executor that delays each submitted task by duration before forwarding to executor.
template<typename F>
auto operator& (executor e, F &&f) -> executor_task_pair< F >
template<typename F>
auto operator& (F &&f, executor e) -> executor_task_pair< F >
void stlab_v2_main_executor_submit (const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source) noexcept
 Submits one task to the main queue.
void stlab_v2_main_executor_run ()
 Keeps the main queue serviced; never returns.
void main_executor_run ()
 Keeps the main queue serviced; never returns.
void set_current_thread_name (const char *name)
stlab_v2_timer_status stlab_v2_system_timer_submit (const unsigned char *task_abi_guard, const stlab_v2_task_concept *vtable, stlab_v2_task_proc invoke, void *source, std::int64_t delay_ns) noexcept
 Accepts a task into the core timer service without propagating exceptions.
void stlab_pre_exit ()
 An extern "C" vector for pre-exit() to make it simpler to export the function from a shared library.
void stlab_at_pre_exit (pre_exit_handler f)
 An extern "C" vector for at_pre-exit() to make it simpler to export the function from a shared library.
void pre_exit ()
 Invoke all registered pre-exit handlers in the reverse order they are registered. It is safe to register additional handlers during this operation. Must be invoked exactly once prior to program exit. Handlers needed to unblock running core work must be registered after the first timer or default-executor use and before invoking pre_exit(). On threadless Emscripten, returns after initiating retirement; the next ordinary main task runs only after executor work and deferred handlers finish. Default/high/low submission remains available during the drain and is a precondition violation after it completes.
void at_pre_exit (pre_exit_handler f)
 Register a pre-exit handler. The pre-exit-handler may not throw. With C++17 or later it is required to be noexcept.

Variables

constexpr auto low_executor
 Low-priority concurrent executor. Portable executors prioritize queued work without changing OS thread priority; Windows and libdispatch use platform priority hints.
constexpr auto default_executor
 Default concurrent executor using the medium-priority queue.
constexpr auto high_executor
 High-priority concurrent executor. Portable executors prioritize queued work without changing OS thread priority; Windows and libdispatch use platform priority hints.
constexpr auto immediate_executor
 Invokes work inline on the calling thread (synchronous executor).
constexpr auto main_executor
 Runs void() noexcept tasks on the configured main queue in submission order, except that cooperative retirement prioritizes main work posted by draining producers. Remains available after pre_exit() so a final queued task can terminate the process.
constexpr auto system_timer
 Schedules move-only void() noexcept tasks through the process-shared timer service.
constexpr std::size_t stlab_v2_task_storage_size
 Number of bytes reserved for a v2 task's relocatable inline model.
constexpr std::size_t stlab_v2_task_storage_alignment
 Alignment required by a v2 task's relocatable inline model.

Function Documentation

◆ stlab_v2_system_timer_submit()

stlab_v2_timer_status stlab::v2::stlab_v2_system_timer_submit ( const unsigned char * task_abi_guard,
const stlab_v2_task_concept * vtable,
stlab_v2_task_proc invoke,
void * source,
std::int64_t delay_ns )
noexcept

Accepts a task into the core timer service without propagating exceptions.

  • Precondition: the task ABI guard and relocation operations describe the live task at source; delay_ns is nonnegative, and pre_exit() has not closed timer admission.
  • Precondition: the target meets the queued-target lifecycle requirement in task.hpp; on threaded task systems, its callback and executed-target cleanup do not call pre_exit().
  • Postcondition: success relocates the target exactly once; failure leaves source unconsumed. Accepted targets are invoked once or canceled, and destroyed once.