pub struct AsyncToken { /* private fields */ }Expand description
A cancellable, generation-gated handle that re-enters an async record’s
process() exactly once.
C parity: epics-base callbackRequest / callbackRequestDelayed
(callback.c) post a one-shot callback that later runs the record’s
(*prset->process)(precord) directly, bypassing dbProcess’s PACT
entry guard. Here, firing the token re-enters via
PvDatabase::process_record_continuation (the owner-driven
continuation that also bypasses the PACT guard).
§Cancellation is structural, not a runtime check
The record owns a monotonic generation counter (reprocess_generation).
Minting a token snapshots that counter as the token’s epoch after
bumping it, so:
- minting a newer token for the same record (C
callbackRequestDelayedreplacing an outstanding delayed callback), or PvDatabase::cancel_async_reentry(CcallbackCancelDelayed),
each advance the counter past every outstanding token’s epoch. A
stale token therefore re-enters nothing: AsyncToken::fire is the
sole re-entry path, the epoch comparison is owned in one place, and the
token is consumed (self by value) so it cannot fire twice. A consumer
never writes an if generation == ... guard — it holds the token and
calls fire; the no-op-when-stale is guaranteed by construction.
Implementations§
Source§impl AsyncToken
impl AsyncToken
Sourcepub fn record_name(&self) -> &str
pub fn record_name(&self) -> &str
The record this token re-enters.
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
True iff this token is still the current generation — no newer
token was minted and no PvDatabase::cancel_async_reentry has
run for the record since this token was minted. Read-only.
Sourcepub fn cancel(self)
pub fn cancel(self)
Cancel this token (C callbackCancelDelayed for the holder’s own
pending re-entry): advance the generation so this and any other
outstanding token for the record become stale, then consume the
token. Use when the holder itself decides not to re-enter; use
PvDatabase::cancel_async_reentry to cancel a token already
handed to a timer / notify task.
Sourcepub async fn fire(self, db: &PvDatabase) -> CaResult<()>
pub async fn fire(self, db: &PvDatabase) -> CaResult<()>
Fire the continuation: if still current, re-enter the record’s
process() via PvDatabase::process_record_continuation. A
stale (superseded / cancelled) token is a no-op. Consumes the
token so it cannot fire twice.