Skip to main content

ElectedClock

Struct ElectedClock 

Source
pub struct ElectedClock { /* private fields */ }
Expand description

The elected pipeline clock as the sinks hold it: a stable shared handle whose target can be replaced (M1004).

ClockSync is handed to each sink once, before any frame flows, and the runner cannot reach the sinks again afterwards (their elements have moved into the arms, on other threads under the thread-per-arm runner). So when the elected clock degrades and the runner re-elects, the way the new choice reaches every sink is this handle: the ClockSync they hold points at the ElectedClock, and swap retargets it in place.

as_ticker stays None here: it lends out a borrow of the clock, which a target that can be replaced cannot give. shared_ticker is owned, so it forwards and follows the swap. The runner only installs this indirection when it is going to monitor clock health; otherwise sinks get the elected clock directly.

Implementations§

Source§

impl ElectedClock

Source

pub fn new(target: Arc<dyn PipelineClock + Send + Sync>) -> Self

A handle pointing at the freshly elected clock.

Source

pub fn swap(&self, target: Arc<dyn PipelineClock + Send + Sync>)

Retarget every holder at target (a re-election). Reads after this see the new clock’s timeline; a sink re-anchors on its next frame the same way it does for any other epoch change.

Source

pub fn target(&self) -> Arc<dyn PipelineClock + Send + Sync>

The clock currently pointed at.

Trait Implementations§

Source§

impl Debug for ElectedClock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PipelineClock for ElectedClock

Source§

fn now_ns(&self) -> u64

Source§

fn shared_ticker(&self) -> Option<Arc<dyn DynAsyncClock + Send + Sync>>

The same timer as as_ticker, as an owned shared handle. The thread-per-arm runner builds each arm’s future on its own OS thread, which a borrow cannot cross, so that is where it reads the tick from instead. Read more
Source§

fn healthy(&self) -> bool

Whether this clock still holds the reference it disciplines to. A clock that tells time from a source it cannot lose (a monotonic counter, a DAC) is always healthy, which is the default; a disciplined clock (PtpClock) reports false once its master is gone. The runner polls the elected clock and, on a loss, posts BusMessage::ClockLost and re-elects over the candidates that are still healthy.
Source§

fn as_ticker(&self) -> Option<&dyn DynAsyncClock>

This clock as a deadline sleeper, when it is one. The cooperative runner reads it to derive a fan-in element’s tick timer (PipelinePacket::Tick, M880) from the pipeline clock itself, so a parse_launch line running against any sleepable clock ticks without a separate entry point. Read more

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> ElementBound for T
where T: Send,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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.