Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::detail::TimeoutController Class Reference

A single owned, cancellable, joinable timeout. More...

#include <trace_timeout.hpp>

Public Member Functions

 TimeoutController ()=default
 TimeoutController (const TimeoutController &)=delete
TimeoutController & operator= (const TimeoutController &)=delete
 ~TimeoutController ()
 Joins any armed timeout. A controller must never outlive its worker.
void arm (std::chrono::milliseconds delay, std::uint64_t generation, std::function< void(std::uint64_t)> on_expire)
 Arm on_expire(generation) to run after delay.
void cancel_and_join ()
 Cancel an armed timeout and join its thread.
bool armed () const noexcept
 True while a timeout thread exists (armed, running, or finished but not yet joined).

Detailed Description

A single owned, cancellable, joinable timeout.

Not thread-safe against concurrent arm() calls — the caller serializes them (trace.cpp holds a dedicated mutex). cancel_and_join() is safe to call from any thread EXCEPT the worker itself, which would self-join.

Constructor & Destructor Documentation

◆ TimeoutController() [1/2]

pulp::runtime::detail::TimeoutController::TimeoutController ( )
default

◆ TimeoutController() [2/2]

pulp::runtime::detail::TimeoutController::TimeoutController ( const TimeoutController & )
delete

◆ ~TimeoutController()

pulp::runtime::detail::TimeoutController::~TimeoutController ( )
inline

Joins any armed timeout. A controller must never outlive its worker.

Member Function Documentation

◆ arm()

void pulp::runtime::detail::TimeoutController::arm ( std::chrono::milliseconds delay,
std::uint64_t generation,
std::function< void(std::uint64_t)> on_expire )
inline

Arm on_expire(generation) to run after delay.

Any previously armed timeout is cancelled and joined first, so two arms cannot leave two timers running against one session.

◆ armed()

bool pulp::runtime::detail::TimeoutController::armed ( ) const
inlinenoexcept

True while a timeout thread exists (armed, running, or finished but not yet joined).

◆ cancel_and_join()

void pulp::runtime::detail::TimeoutController::cancel_and_join ( )
inline

Cancel an armed timeout and join its thread.

No-op when nothing is armed. Returns only once the worker is guaranteed not to run again — which is what makes module unload safe.

◆ operator=()

TimeoutController & pulp::runtime::detail::TimeoutController::operator= ( const TimeoutController & )
delete

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