pub trait TimerPollOps {
// Required methods
fn new() -> TimerResult<Self>
where Self: Sized;
fn add(&self, timer: TimerFd) -> TimerResult<()>;
fn delete<FD: FdTimerMarker>(&self, timer: &FD) -> TimerResult<()>;
fn poll(
&self,
timeout: Option<i32>,
) -> TimerResult<Option<Vec<PollEventType>>>;
fn get_count(&self) -> usize;
fn get_poll_interruptor(&self) -> PollInterrupt;
fn interrupt_poll(&self) -> bool;
}Expand description
A standart functions for each timer.
Required Methods§
Sourcefn new() -> TimerResult<Self>where
Self: Sized,
fn new() -> TimerResult<Self>where
Self: Sized,
Sourcefn add(&self, timer: TimerFd) -> TimerResult<()>
fn add(&self, timer: TimerFd) -> TimerResult<()>
Adds the timer to the event monitor. It accepts any reference to instance which implements [AsFd] and it is not limited specificly to timers. Maybe later this behaviour will me modified.
§Arguments
timer- TimerFd
§Returns
A TimerResult i.e Result is returned with error description in case of error.
Sourcefn delete<FD: FdTimerMarker>(&self, timer: &FD) -> TimerResult<()>
fn delete<FD: FdTimerMarker>(&self, timer: &FD) -> TimerResult<()>
Removes the specific timer’s FD from the event monitor.
§Arguments
timer-FDwhere impl FdTimerMarker a timer instance.
§Returns
A TimerResult i.e Result is returned with error description in case of error.
Sourcefn poll(&self, timeout: Option<i32>) -> TimerResult<Option<Vec<PollEventType>>>
fn poll(&self, timeout: Option<i32>) -> TimerResult<Option<Vec<PollEventType>>>
Polls the event monitor for events. Depending on the timeout the behaviour will
be different.
§Arguments
timeout- poll timeout. If set to Option::None will block the current thread. If set to Option::Some with inner value0will return immidiatly. The timeout is set inmiliseconds.
§Returns
A TimerResult i.e Result is returned with
-
Result::Ok with the [PollResult] where:
-
[PollResult::Some] with the Vec with the [RawFd] of the timer’s where the event has happened.
-
[PollResult::None] if no events happened.
-
[PollResult::TimerRemoved] if timer was removed during polling operation. Otherwise, it will not be returned. If timer was cancelled and another timer times out, the
TimerRemovedwill be supressed in favor of the [PollResult::Some].
-
-
Result::Err with error description.
Sourcefn get_poll_interruptor(&self) -> PollInterrupt
fn get_poll_interruptor(&self) -> PollInterrupt
Sourcefn interrupt_poll(&self) -> bool
fn interrupt_poll(&self) -> bool
Attempts to interrupt the poll operaiton. If successfull returns true.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.