Skip to main content

Event

Struct Event 

Source
pub struct Event<T> { /* private fields */ }
Expand description

A scheduled event stored in the wheel.

Event values are returned by read/pop/remove operations. They carry metadata used by the wheel scheduler:

  • tick: absolute tick when the event can be processed.
  • delta_tick: wave index within the same tick.

§Example

use okee_wheel_timer::HashedWheelTimer;

let mut wheel = HashedWheelTimer::new(8);
let id = wheel.schedule(0, "payload").id;

let events = wheel.pop_events();
assert_eq!(events[0].id(), id);
assert_eq!(events[0].tick(), 0);
assert_eq!(events[0].data(), &"payload");

Implementations§

Source§

impl<T> Event<T>

Source

pub fn id(&self) -> EventId

Returns the unique ID of this event.

Source

pub fn tick(&self) -> u64

Returns the absolute tick when this event becomes available.

Source

pub fn delta_tick(&self) -> u64

Returns the wave number inside tick.

Events with the same (tick, delta_tick) are popped together.

Source

pub fn data(&self) -> &T

Returns a shared reference to the payload.

Source

pub fn into_data(self) -> T

Consumes the event and returns its payload.

Trait Implementations§

Source§

impl<T: Clone> Clone for Event<T>

Source§

fn clone(&self) -> Event<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Event<T>

Source§

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

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

impl<T: Copy> Copy for Event<T>

Auto Trait Implementations§

§

impl<T> Freeze for Event<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Event<T>
where T: RefUnwindSafe,

§

impl<T> Send for Event<T>
where T: Send,

§

impl<T> Sync for Event<T>
where T: Sync,

§

impl<T> Unpin for Event<T>
where T: Unpin,

§

impl<T> UnwindSafe for Event<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.