pub struct Schedule<Item: Schedulable> { /* private fields */ }Expand description
A schedule for managing Schedulable items.
The Schedule structure stores items indexed by their unique
identifiers and groups item id by their interval. This allows
efficient lookup of items by id and retrieval of all id in a
given interval.
| Operation | Time complexity |
|---|---|
| Get | O(1) |
| Get due | O(m) |
| Insert | O(1) |
| Remove | O(1) |
m - it’s amount of unique intervals.
Implementations§
Source§impl<Item: Schedulable> Schedule<Item>
impl<Item: Schedulable> Schedule<Item>
Sourcepub async fn get_due(&self, from: i64, to: i64) -> Vec<Arc<Item>>
pub async fn get_due(&self, from: i64, to: i64) -> Vec<Arc<Item>>
Get items that are included in the interval from and to.
An element is included in the interval if there is at least
one value between from and to that is divisible by
the item’s interval without a remainder.
from and to should be > 0 and from should be <= to.
Auto Trait Implementations§
impl<Item> !Freeze for Schedule<Item>
impl<Item> !RefUnwindSafe for Schedule<Item>
impl<Item> Send for Schedule<Item>where
RwLock<HashMap<<Item as Schedulable>::Id, Arc<Item>>>: Send,
RwLock<HashMap<<Item as Schedulable>::Interval, HashSet<<Item as Schedulable>::Id>>>: Send,
impl<Item> Sync for Schedule<Item>where
RwLock<HashMap<<Item as Schedulable>::Id, Arc<Item>>>: Sync,
RwLock<HashMap<<Item as Schedulable>::Interval, HashSet<<Item as Schedulable>::Id>>>: Sync,
impl<Item> Unpin for Schedule<Item>where
RwLock<HashMap<<Item as Schedulable>::Id, Arc<Item>>>: Unpin,
RwLock<HashMap<<Item as Schedulable>::Interval, HashSet<<Item as Schedulable>::Id>>>: Unpin,
impl<Item> UnsafeUnpin for Schedule<Item>where
RwLock<HashMap<<Item as Schedulable>::Id, Arc<Item>>>: UnsafeUnpin,
RwLock<HashMap<<Item as Schedulable>::Interval, HashSet<<Item as Schedulable>::Id>>>: UnsafeUnpin,
impl<Item> UnwindSafe for Schedule<Item>where
RwLock<HashMap<<Item as Schedulable>::Id, Arc<Item>>>: UnwindSafe,
RwLock<HashMap<<Item as Schedulable>::Interval, HashSet<<Item as Schedulable>::Id>>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more