RandomAccessScheduler

Struct RandomAccessScheduler 

Source
pub struct RandomAccessScheduler<'a, G>
where G: TimeGenerator,
{ /* private fields */ }
Expand description

A random-access scheduler.

A random-access scheduler gives you an interesting property: given any time, it will perform resolution of the action to use based on the logarithm of the number of windows being scheduled. That gives good performance for someone who is constantly changing time without ticking or unticking with a small delta.

On the opposite hand, if you don’t need that random-access property, then a sequential scheduler will make a way better job for you (it will give you a O(1) runtime performance instead of O(log N)).

Note: if you use a sequential scheduler by doing random-accesses, you are basically ruining the initial concept of a sequential scheduler (it will run in O(N) at worst).

Implementations§

Source§

impl<'a, G> RandomAccessScheduler<'a, G>
where G: TimeGenerator,

Source

pub fn new<W>(time_gen: G, windows: W) -> Option<Self>
where W: Into<Vec<MappedWindow<'a, G::Time>>>,

Create a new random-access scheduler.

This function might fail if the time windows are overlapping.

Source

pub fn schedule(&mut self)

Schedule the mapped windows.

Source

pub fn interruptible_with<F>(&mut self, interrupt: F)
where F: FnMut(G::Time) -> Interrupt + 'a,

Make the scheduler interruptible with the given function

Note: the function must not block and return as soon as possible.

Auto Trait Implementations§

§

impl<'a, G> Freeze for RandomAccessScheduler<'a, G>
where G: Freeze,

§

impl<'a, G> !RefUnwindSafe for RandomAccessScheduler<'a, G>

§

impl<'a, G> !Send for RandomAccessScheduler<'a, G>

§

impl<'a, G> !Sync for RandomAccessScheduler<'a, G>

§

impl<'a, G> Unpin for RandomAccessScheduler<'a, G>
where G: Unpin, <G as TimeGenerator>::Time: Unpin,

§

impl<'a, G> !UnwindSafe for RandomAccessScheduler<'a, G>

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