Trait kernel::time::hrtimer::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§
sourceunsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>
unsafe fn raw_get_timer(this: *const Self) -> *const HrTimer<T>
sourceunsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Selfwhere
Self: Sized,
unsafe fn timer_container_of(ptr: *mut HrTimer<T>) -> *mut Selfwhere
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§
sourceunsafe fn c_timer_ptr(this: *const Self) -> *const hrtimer
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.
sourceunsafe fn start(this: *const Self, expires: Ktime)
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 validSelf
.- Caller must ensure that the pointee of
this
lives until the timer fires or is canceled.