Struct os_timer::Timer [−][src]
pub struct Timer { /* fields omitted */ }
Expand description
Posix timer wrapper
Implementations
impl Timer
[src]
impl Timer
[src]pub const unsafe fn uninit() -> Self
[src]
pub const unsafe fn uninit() -> Self
[src]Creates new uninitialized instance.
In order to use it one must call init
.
#[must_use]pub fn init(&self, cb: Callback) -> bool
[src]
#[must_use]pub fn init(&self, cb: Callback) -> bool
[src]Performs timer initialization
cb
pointer to function to invoke when timer expires.
Returns whether timer has been initialized successfully or not.
If timer is already initialized does nothing, returning false.
pub fn new(cb: Callback) -> Option<Self>
[src]
pub fn new(cb: Callback) -> Option<Self>
[src]Creates new timer, invoking provided cb
when timer expires.
On failure, returns None
pub fn schedule_interval(&self, timeout: Duration, interval: Duration) -> bool
[src]
pub fn schedule_interval(&self, timeout: Duration, interval: Duration) -> bool
[src]Schedules timer to alarm periodically with interval
with initial alarm of timeout
.
Note that if timer has been scheduled before, but hasn’t expire yet, it shall be cancelled.
To prevent that user must cancel
timer first.
Returns true
if successfully set, otherwise on error returns false
pub fn is_scheduled(&self) -> bool
[src]
pub fn is_scheduled(&self) -> bool
[src]Returns true
if timer has been scheduled and still pending.
On Win/Mac it only returns whether timer has been scheduled, as there is no way to check whether timer is ongoing
impl Timer
[src]
impl Timer
[src]pub fn schedule_once(&self, timeout: Duration) -> bool
[src]
pub fn schedule_once(&self, timeout: Duration) -> bool
[src]Schedules timer to alarm once after timeout
passes.
Note that if timer has been scheduled before, but hasn’t expire yet, it shall be cancelled.
To prevent that user must cancel
timer first.
Returns true
if successfully set, otherwise on error returns false