ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
esphome::SchedulerCallback Class Reference

Type-erased scheduler callable, built from a callable at the call site: inline when small and trivially copyable, else heap-boxed. More...

#include <scheduler_callback.h>

Public Member Functions

template<typename F >
requires std::invocable<std::decay_t<F> &>
 SchedulerCallback (F &&f)
 
 SchedulerCallback (const SchedulerCallback &)=delete
 
SchedulerCallback & operator= (const SchedulerCallback &)=delete
 
 ~SchedulerCallback ()
 

Static Public Attributes

static constexpr size_t INLINE_WORDS = 3
 
template<typename F >
static constexpr bool FITS_INLINE
 

Detailed Description

Type-erased scheduler callable, built from a callable at the call site: inline when small and trivially copyable, else heap-boxed.

A function taking SchedulerCallback && must pass it to the scheduler once, on every path: one that is dropped leaks its box and what it captured. A boxed capture's destructor runs with the scheduler lock held (as with std::function before), so it must not call the scheduler; the exception is a SCHEDULER_DONT_RUN callback, freed after the lock is released, which may reschedule its own key. Not Callback::create_boxed() (helpers.h): this keeps release inline and shares one ::operator delete for all trivially destructible boxes.

Definition at line 21 of file scheduler_callback.h.

Constructor & Destructor Documentation

◆ SchedulerCallback() [1/2]

template<typename F >
requires std::invocable<std::decay_t<F> &>
esphome::SchedulerCallback::SchedulerCallback ( F && f)
inline

Definition at line 31 of file scheduler_callback.h.

◆ SchedulerCallback() [2/2]

esphome::SchedulerCallback::SchedulerCallback ( const SchedulerCallback & )
delete

◆ ~SchedulerCallback()

esphome::SchedulerCallback::~SchedulerCallback ( )
inline

Definition at line 51 of file scheduler_callback.h.

Member Function Documentation

◆ operator=()

SchedulerCallback & esphome::SchedulerCallback::operator= ( const SchedulerCallback & )
delete

Field Documentation

◆ [struct]

struct { ... } esphome::SchedulerCallback::boxed_

◆ bytes_

unsigned char esphome::SchedulerCallback::bytes_[INLINE_WORDS *sizeof(uintptr_t)]

Definition at line 92 of file scheduler_callback.h.

◆ FITS_INLINE

template<typename F >
bool esphome::SchedulerCallback::FITS_INLINE
staticconstexpr
Initial value:
= sizeof(F) <= INLINE_WORDS * sizeof(uintptr_t) &&
alignof(F) <= alignof(uintptr_t) && std::is_trivially_copyable_v<F>
static constexpr size_t INLINE_WORDS

Definition at line 26 of file scheduler_callback.h.

◆ INLINE_WORDS

size_t esphome::SchedulerCallback::INLINE_WORDS = 3
staticconstexpr

Definition at line 23 of file scheduler_callback.h.

◆ obj

void* esphome::SchedulerCallback::obj

Definition at line 94 of file scheduler_callback.h.

◆ release

void(* esphome::SchedulerCallback::release) (void *obj)

Definition at line 96 of file scheduler_callback.h.

◆ run

void(* esphome::SchedulerCallback::run) (void *obj)

Definition at line 95 of file scheduler_callback.h.


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