pub struct TimerHandle { /* private fields */ }Expand description
Handle to a scheduled timer with RAII cancellation.
When dropped, the handle automatically cancels the timer if it hasn’t fired yet. This follows the RAII pattern for resource management.
§Example
use reovim_kernel::api::v1::*;
use std::time::Duration;
let mut runtime = Runtime::new();
runtime.boot();
{
// Timer is scheduled
let handle = runtime.schedule_delayed(Duration::from_secs(10), || {
println!("This won't print");
});
// handle dropped here - timer is cancelled
}
// Timer was cancelled, won't fire§Manual Cancellation
You can also explicitly cancel via Runtime::cancel_timer:
use reovim_kernel::api::v1::*;
use std::time::Duration;
let mut runtime = Runtime::new();
runtime.boot();
let handle = runtime.schedule_delayed(Duration::from_secs(10), || {});
let id = handle.id();
// Explicit cancellation
std::mem::forget(handle); // Prevent drop cancellation
let was_pending = runtime.cancel_timer(id);Implementations§
Trait Implementations§
Source§impl Debug for TimerHandle
impl Debug for TimerHandle
Auto Trait Implementations§
impl Freeze for TimerHandle
impl !RefUnwindSafe for TimerHandle
impl Send for TimerHandle
impl Sync for TimerHandle
impl Unpin for TimerHandle
impl UnsafeUnpin for TimerHandle
impl !UnwindSafe for TimerHandle
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
Mutably borrows from an owned value. Read more