Skip to main content

AsyncToken

Struct AsyncToken 

Source
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 callbackRequestDelayed replacing an outstanding delayed callback), or
  • PvDatabase::cancel_async_reentry (C callbackCancelDelayed),

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

Source

pub fn record_name(&self) -> &str

The record this token re-enters.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more