TimerPollOps

Trait TimerPollOps 

Source
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§

Source

fn new() -> TimerResult<Self>
where Self: Sized,

Creates new default instance.

§Returns

A TimerResult is returned with instance on success.

Source

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.

Source

fn delete<FD: FdTimerMarker>(&self, timer: &FD) -> TimerResult<()>

Removes the specific timer’s FD from the event monitor.

§Arguments
§Returns

A TimerResult i.e Result is returned with error description in case of error.

Source

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 value 0 will return immidiatly. The timeout is set in miliseconds.
§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 TimerRemoved will be supressed in favor of the [PollResult::Some].

  • Result::Err with error description.

Source

fn get_count(&self) -> usize

Returns the amount of timer’s FDs

Source

fn get_poll_interruptor(&self) -> PollInterrupt

Provides a Weak reference to the wakeup EventFd.

Source

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.

Implementors§