pub struct DispatcherTimer { /* private fields */ }Expand description
A timer that is integrated into the Dispatcher queues, and will be
processed after a given amount of time at a specified priority.
Timers belong to the thread of their dispatcher: they are created,
started and stopped there, and that is where tick handlers run. To
start a timer from another thread, post a job that creates it.
Implementations§
Source§impl DispatcherTimer
impl DispatcherTimer
Sourcepub fn new() -> Rc<DispatcherTimer>
pub fn new() -> Rc<DispatcherTimer>
Creates a timer that uses the current thread’s dispatcher to process the timer event at background priority.
Sourcepub fn with_priority(priority: DispatcherPriority) -> Rc<DispatcherTimer>
pub fn with_priority(priority: DispatcherPriority) -> Rc<DispatcherTimer>
Creates a timer that uses the current thread’s dispatcher to process the timer event at the specified priority.
Sourcepub fn with_priority_and_dispatcher(
priority: DispatcherPriority,
dispatcher: &Arc<Dispatcher>,
) -> Rc<DispatcherTimer>
pub fn with_priority_and_dispatcher( priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>, ) -> Rc<DispatcherTimer>
Creates a timer that uses the specified dispatcher to process the timer event at the specified priority.
Sourcepub fn with_interval(
interval: Duration,
priority: DispatcherPriority,
dispatcher: &Arc<Dispatcher>,
) -> Rc<DispatcherTimer>
pub fn with_interval( interval: Duration, priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>, ) -> Rc<DispatcherTimer>
Creates a timer that uses the specified dispatcher to process the timer event at the specified priority after the specified interval.
§Panics
Panics when the priority is invalid or inactive, when the interval is
longer than i32::MAX milliseconds and when called from a thread
other than the dispatcher’s.
Sourcepub fn with_callback(
interval: Duration,
priority: DispatcherPriority,
callback: impl Fn(&DispatcherTimer) + 'static,
) -> Rc<DispatcherTimer>
pub fn with_callback( interval: Duration, priority: DispatcherPriority, callback: impl Fn(&DispatcherTimer) + 'static, ) -> Rc<DispatcherTimer>
Creates a timer that is bound to the current thread’s dispatcher and will be processed after the specified interval, at the specified priority, calling the specified handler. The timer is started.
Sourcepub fn with_callback_and_dispatcher(
interval: Duration,
priority: DispatcherPriority,
dispatcher: &Arc<Dispatcher>,
callback: impl Fn(&DispatcherTimer) + 'static,
) -> Rc<DispatcherTimer>
pub fn with_callback_and_dispatcher( interval: Duration, priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>, callback: impl Fn(&DispatcherTimer) + 'static, ) -> Rc<DispatcherTimer>
Creates a timer that is bound to the specified dispatcher and will be processed after the specified interval, at the specified priority, calling the specified handler. The timer is started.
Sourcepub fn dispatcher(&self) -> &Arc<Dispatcher> ⓘ
pub fn dispatcher(&self) -> &Arc<Dispatcher> ⓘ
Gets the dispatcher this timer is associated with.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Gets whether the timer is running.
Sourcepub fn set_is_enabled(&self, value: bool)
pub fn set_is_enabled(&self, value: bool)
Starts or stops the timer.
Sourcepub fn set_interval(&self, value: Duration)
pub fn set_interval(&self, value: Duration)
Sets the time between timer ticks.
Sourcepub fn run(
action: impl Fn() -> bool + 'static,
interval: Duration,
priority: DispatcherPriority,
) -> Rc<dyn IDisposable>
pub fn run( action: impl Fn() -> bool + 'static, interval: Duration, priority: DispatcherPriority, ) -> Rc<dyn IDisposable>
Starts a new timer.
action is called on each tick; the timer stops when it returns
false. Disposing the returned value stops the timer.
Sourcepub fn run_once(
action: impl Fn() + 'static,
interval: Duration,
priority: DispatcherPriority,
) -> Rc<dyn IDisposable>
pub fn run_once( action: impl Fn() + 'static, interval: Duration, priority: DispatcherPriority, ) -> Rc<dyn IDisposable>
Runs a method once, after the specified interval.
Disposing the returned value cancels the timer.
Sourcepub fn tick(
&self,
handler: impl Fn(&DispatcherTimer) + 'static,
) -> Rc<dyn IDisposable>
pub fn tick( &self, handler: impl Fn(&DispatcherTimer) + 'static, ) -> Rc<dyn IDisposable>
Occurs when the specified timer interval has elapsed and the timer is enabled.
Sourcepub fn tag(&self) -> Option<BoxedValue>
pub fn tag(&self) -> Option<BoxedValue>
Any data that the caller wants to pass along with the timer.
pub fn set_tag(&self, value: Option<BoxedValue>)
Auto Trait Implementations§
impl !Freeze for DispatcherTimer
impl !RefUnwindSafe for DispatcherTimer
impl !Send for DispatcherTimer
impl !Sync for DispatcherTimer
impl !UnwindSafe for DispatcherTimer
impl Unpin for DispatcherTimer
impl UnsafeUnpin for DispatcherTimer
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more