Skip to main content

Module background

Module background 

Source
Expand description

RTEMS-side background-execution infrastructure (CA sans-io refactor, increment W3a — the seam backend).

§Why this exists (decision A2)

The CA server is being made runnable on RTEMS (armv7-rtems-eabihf) with one async engine. On a hosted target, async tails — PACT device completion, FLNK/scanOnce chains, SDLY/ODLY/watchdog timers, WRITE_NOTIFY completion — run as tokio tasks via crate::runtime::task::spawn. RTEMS has no tokio runtime (tokio::spawn/tokio::time need one), so those tails need a runtime-free home. This module is that home: three C-parity facilities built from plain std threads + Mutex/Condvar, carrying no tokio dependency.

FacilityC sourceRust
callback_executorcallback.c callbackQueue[]/callbackTaskpriority-banded worker pool
delayed_timercallback.c callbackRequestDelayed/timerQueueone deadline-ordered timer thread
scan_oncedbScan.c onceQ/scanOnce/onceTaskbounded ring + one worker

§The seam handle

BackgroundExecutor owns the three facilities and their threads; BackgroundExecutor::handle hands out a cheap, clonable BackgroundHandle that the future seam wiring routes synchronous-tail hand-offs through. The hosted (tokio) build keeps calling crate::runtime::task::spawn — this module is only the RTEMS route, and this increment adds the infrastructure without switching any call site over to it (that is a later increment).

Re-exports§

pub use callback_executor::Callback;
pub use callback_executor::CallbackError;
pub use callback_executor::CallbackHandle;
pub use callback_executor::CallbackPool;
pub use callback_executor::CallbackPriority;
pub use callback_executor::DEFAULT_QUEUE_SIZE;
pub use callback_executor::DEFAULT_THREADS_PER_PRIORITY;
pub use callback_executor::NUM_CALLBACK_PRIORITIES;
pub use delayed_timer::DelayedTimer;
pub use delayed_timer::TimerHandle;
pub use future_exec::AbortHandle;
pub use future_exec::DEFAULT_SPAWN_PRIORITY;
pub use future_exec::JoinError;
pub use future_exec::JoinFuture;
pub use future_exec::spawn_blocking_on;
pub use future_exec::spawn_future;
pub use scan_once::DEFAULT_ONCE_QUEUE_SIZE;
pub use scan_once::OnceCallback;
pub use scan_once::ScanOnceHandle;
pub use scan_once::ScanOnceOverflow;
pub use scan_once::ScanOnceQueue;

Modules§

callback_executor
General-purpose callback executor pool — RTEMS-safe port of modules/database/src/ioc/db/callback.c.
delayed_timer
Delayed-callback timer facility — RTEMS-safe port of callbackRequestDelayed and its epicsTimerQueue usage in modules/database/src/ioc/db/callback.c.
facility
What keeps a facility thread alive, and what is said when one dies.
future_exec
Runtime-free future executor over the callback pool — the RTEMS backend for crate::runtime::task::spawn / crate::runtime::task::spawn_blocking (decision A2, increment W3b).
scan_once
scanOnce queue + worker — RTEMS-safe port of the onceQ/scanOnce/ onceTask machinery in modules/database/src/ioc/db/dbScan.c.
timer_sleep
Timer-backed sleep / sleep_until futures — the RTEMS backend for crate::runtime::task::sleep / crate::runtime::task::sleep_until (decision A2, increment W3b item 4).

Structs§

BackgroundExecutor
Owns the three background facilities (callback pool, delayed timer, scanOnce worker) and every thread backing them. Constructing it starts the threads; dropping it stops and joins them.
BackgroundHandle
Cheap, clonable submission side of a BackgroundExecutor. Every method enqueues and returns immediately; the work runs on a background thread.