Skip to main content

Module callback_executor

Module callback_executor 

Source
Expand description

General-purpose callback executor pool — RTEMS-safe port of modules/database/src/ioc/db/callback.c.

§C parity

C callback.c runs NUM_CALLBACK_PRIORITIES == 3 (callback.h:40) independent priority bands — priorityLow/priorityMedium/priorityHigh = 0/1/2 (callback.h:41-43) — each with its own bounded ring buffer, its own wake-up event, and callbackThreadsDefault == 1 worker thread(s) (callback.c:66, sized by threadsConfigured). callbackRequest (callback.c:341) pushes an epicsCallback onto the band’s ring and signals the band’s event; callbackTask (callback.c:210) waits on the event, drains the ring, and invokes each callback.

This module keeps that structure but with plain std threads + Mutex/Condvar and boxed closures instead of C function pointers, so it carries no tokio-runtime dependency and runs on RTEMS (armv7-rtems-eabihf). The OS thread priority per band is applied best-effort via the existing apply_to_current_thread abstraction in crate::runtime::task — this module does not duplicate that logic.

§Overflow hysteresis (callback.c:365-374, :227)

C sets a per-band queueOverflow flag when a push finds the ring full; a subsequent callbackRequest returns S_db_bufFull immediately (callback.c:365) without even attempting a push, until a worker pops an entry and clears the flag (callback.c:227). We reproduce that exact latch: once overflow is set, request rejects until a worker drains one entry.

Structs§

CallbackHandle
Cheap, clonable submission side of a CallbackPool — the seam route for RTEMS synchronous-tail hand-offs (increment W3a, decision A2). Holds only Arcs to the bands, so cloning is free and it can be handed to the delayed timer, scanOnce worker, and future engine wiring.
CallbackPool
The callback executor pool: three independent priority bands, each with its own bounded ring and worker thread(s). Port of the callbackQueue[] + callbackTask machinery in callback.c.

Enums§

CallbackError
Why a CallbackHandle::request was rejected.
CallbackPriority
Callback priority band — C priorityLow/priorityMedium/priorityHigh (callback.h:41-43).

Constants§

DEFAULT_QUEUE_SIZE
Default per-band ring capacity — C callbackQueueSize (callback.c:51).
DEFAULT_THREADS_PER_PRIORITY
Default worker threads per band — C callbackThreadsDefault (callback.c:66).
NUM_CALLBACK_PRIORITIES
Number of callback priority bands — C NUM_CALLBACK_PRIORITIES (callback.h:40).

Type Aliases§

Callback
A unit of deferred work. The C epicsCallback is a function pointer plus user data; the Rust port boxes a FnOnce closure that already captures its context.