execution 1.0.1
Portable task execution, timers, and process lifecycle
Loading...
Searching...
No Matches
system_timer.hpp File Reference

Asynchronous delayed execution through the process-shared timer service. More...

#include <stlab/concurrency/task.hpp>
#include <stlab/execution/config.hpp>
#include <stlab/pre_exit.hpp>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <limits>
#include <new>
#include <stdexcept>
#include <system_error>
#include <type_traits>

Go to the source code of this file.

Classes

struct  stlab::v2::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...

Typedefs

using stlab::stlab_v2_task_proc
 Invocation operation for a relocated void() noexcept task.

Functions

stlab_v2_timer_status stlab::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.

Variables

constexpr auto stlab::system_timer
 Schedules move-only void() noexcept tasks through the process-shared timer service.

Detailed Description

Asynchronous delayed execution through the process-shared timer service.

Positive delays round upward to the timer resolution; execution can be late, never early. Nonpositive delays and past steady-clock deadlines request asynchronous execution without delay. pre_exit() closes admission, destroys canceled captures, and waits for committed callbacks on other threads through one core cleanup handler registered at first timer or default-executor use. Application handlers registered afterward run first, in LIFO order, and can signal callbacks. The core handler releases pending timer captures before joining default executors. When pre_exit() blocks the main thread, workers and timer callbacks must not synchronously require main-queue progress. The shared core handler does not close or drain the main queue. On threadless Emscripten, timer cancellation finishes during pre_exit(), but executor retirement and remaining handlers finish asynchronously before the next ordinary main task. On native platforms timer callbacks and their executed-target cleanup must not call pre_exit(); violations assert and terminate. Client modules supplying task operations must remain loaded until their accepted tasks have completed or have been canceled and destroyed.

Queued targets must meet the lifecycle requirement in task.hpp: construction and moved-from destruction must not submit work. Timer callbacks and executed-target cleanup may submit additional work while admission remains open.