Struct netstack3_base::LocalTimerHeap

source ·
pub struct LocalTimerHeap<K, V, BT: TimerBindingsTypes + InstantBindingsTypes> { /* private fields */ }
Expand description

A local timer heap that keeps timers for core modules.

LocalTimerHeap manages its wakeups through a TimerContext.

K is the key that timers are keyed on. V is optional sidecar data to be kept with each timer.

Note that to provide fast timer deletion, LocalTimerHeap requires K to be Clone and the implementation assumes that the clone is cheap.

Implementations§

source§

impl<K, V, BC> LocalTimerHeap<K, V, BC>
where K: Hash + Eq + Clone, BC: TimerContext,

source

pub fn new(bindings_ctx: &mut BC, dispatch_id: BC::DispatchId) -> Self

Creates a new LocalTimerHeap with wakeup dispatch ID dispatch_id.

source

pub fn new_with_context<D, CC: CoreTimerContext<D, BC>>( bindings_ctx: &mut BC, dispatch_id: D, ) -> Self

Like [new] but uses CC to covert the dispatch_id to match the type required by BC.

source

pub fn schedule_instant( &mut self, bindings_ctx: &mut BC, timer: K, value: V, at: BC::Instant, ) -> Option<(BC::Instant, V)>

Schedules timer with value at or after at.

If timer was already scheduled, returns the previously scheduled instant and the associated value.

source

pub fn schedule_after( &mut self, bindings_ctx: &mut BC, timer: K, value: V, after: Duration, ) -> Option<(BC::Instant, V)>

Like [schedule_instant] but does the instant math from current time.

§Panics

Panics if the current BC::Instant cannot be represented by adding duration after.

source

pub fn pop(&mut self, bindings_ctx: &mut BC) -> Option<(K, V)>

Pops an expired timer from the heap, if any.

source

pub fn get(&self, timer: &K) -> Option<(BC::Instant, &V)>

Returns the scheduled instant and associated value for timer, if it’s scheduled.

source

pub fn cancel( &mut self, bindings_ctx: &mut BC, timer: &K, ) -> Option<(BC::Instant, V)>

Cancels timer, returning the scheduled instant and associated value if any.

source

pub fn iter(&self) -> impl Iterator<Item = (&K, &V, &BC::Instant)>

Gets an iterator over the installed timers.

Trait Implementations§

source§

impl<K: Debug, V: Debug, BT: Debug + TimerBindingsTypes + InstantBindingsTypes> Debug for LocalTimerHeap<K, V, BT>
where BT::Timer: Debug, BT::Instant: Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V, BT> Freeze for LocalTimerHeap<K, V, BT>

§

impl<K, V, BT> RefUnwindSafe for LocalTimerHeap<K, V, BT>

§

impl<K, V, BT> Send for LocalTimerHeap<K, V, BT>
where K: Send, V: Send,

§

impl<K, V, BT> Sync for LocalTimerHeap<K, V, BT>
where K: Sync, V: Sync,

§

impl<K, V, BT> Unpin for LocalTimerHeap<K, V, BT>

§

impl<K, V, BT> UnwindSafe for LocalTimerHeap<K, V, BT>

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, 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<CC, BC, Meta> RecvFrameContext<Meta, BC> for CC
where Meta: ReceivableFrameMeta<CC, BC>,

source§

fn receive_frame<B>(&mut self, bindings_ctx: &mut BC, metadata: Meta, frame: B)
where B: BufferMut + Debug,

Receive a frame. Read more
source§

impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CC
where Meta: SendableFrameMeta<CC, BC>,

source§

fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
source§

impl<Id, CC, BC> TimerHandler<BC, Id> for CC
where BC: TimerBindingsTypes, Id: HandleableTimer<CC, BC>,

source§

fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )

Handle a timer firing. Read more
source§

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

§

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>,

§

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.
§

impl<L, T> UnlockedAccess<L> for T
where L: UnlockedAccessMarkerFor<T>,

§

type Data = <L as UnlockedAccessMarkerFor<T>>::Data

The type of state being accessed.
§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where T: 'l

A guard providing read access to the data.
§

fn access(&self) -> <T as UnlockedAccess<L>>::Guard<'_>

How to access the state.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,