[−][src]Struct gaea::Timers
Timer readiness queue.
Polling this event source never returns an error.
Examples
use std::time::Instant; use gaea::{Event, Timers, Ready, event, poll}; let mut timers = Timers::new(); let mut events = Vec::new(); // Add a deadline, to trigger an event immediately. let id = event::Id(0); timers.add_deadline(id, Instant::now()); // Now we poll for events. Note that this is safe to unwrap as polling // `Timers` never returns an error. poll::<_, ()>(&mut [&mut timers], &mut events, None).unwrap(); assert_eq!(events.get(0), Some(&Event::new(id, Ready::TIMER)));
Methods
impl Timers
[src]
pub fn new() -> Timers
[src]
Create a new time event source.
pub fn add_deadline(&mut self, id: Id, deadline: Instant)
[src]
Add a new deadline.
This will cause an event to trigger after the deadline
has passed with
the Ready::TIMER
readiness and provided id
.
pub fn add_timeout(&mut self, id: Id, timeout: Duration)
[src]
Add a new timeout.
This is the same as add_deadline
, but then using a Duration
, see
add_deadline
for more information.
pub fn remove_deadline(&mut self, id: Id)
[src]
Remove a previously added deadline.
Notes
Removing a deadline is a costly operation. For better performance it is advised to not bother with removing and instead ignore the event when it comes up.
Trait Implementations
impl<ES, E> Source<ES, E> for Timers where
ES: Sink,
[src]
ES: Sink,
fn max_timeout(&self) -> Option<Duration>
[src]
fn poll(&mut self, event_sink: &mut ES) -> Result<(), E>
[src]
fn blocking_poll(
&mut self,
event_sink: &mut ES,
timeout: Option<Duration>
) -> Result<(), E>
[src]
&mut self,
event_sink: &mut ES,
timeout: Option<Duration>
) -> Result<(), E>
A blocking poll for readiness events. Read more
impl Default for Timers
[src]
impl Debug for Timers
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,