Trait HasHrTimer

Source
pub unsafe trait HasHrTimer<T> {
    // Required methods
    unsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>;
    unsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Self
       where Self: Sized;

    // Provided methods
    unsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer { ... }
    unsafe fn start(this: *const Self, expires: Ktime) { ... }
}
Expand description

Implemented by structs that contain timer nodes.

Clients of the timer API would usually safely implement this trait by using the crate::impl_has_hr_timer macro.

§Safety

Implementers of this trait must ensure that the implementer has a HrTimer field and that all trait methods are implemented according to their documentation. All the methods of this trait must operate on the same field.

Required Methods§

Source

unsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>

Return a pointer to the HrTimer within Self.

This function is useful to get access to the value without creating intermediate references.

§Safety

this must be a valid pointer.

Source

unsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Self
where Self: Sized,

Return a pointer to the struct that is containing the HrTimer pointed to by ptr.

This function is useful to get access to the value without creating intermediate references.

§Safety

ptr must point to a HrTimer<T> field in a struct of type Self.

Provided Methods§

Source

unsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer

Get pointer to the contained bindings::hrtimer struct.

This function is useful to get access to the value without creating intermediate references.

§Safety

this must be a valid pointer.

Source

unsafe fn start(this: *const Self, expires: Ktime)

Start the timer contained in the Self pointed to by self_ptr. If it is already running it is removed and inserted.

§Safety
  • this must point to a valid Self.
  • Caller must ensure that the pointee of this lives until the timer fires or is canceled.

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§