Trait kernel::workqueue::RawWorkItem
source · pub unsafe trait RawWorkItem<const ID: u64> {
type EnqueueOutput;
// Required method
unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput
where F: FnOnce(*mut work_struct) -> bool;
}
Expand description
A raw work item.
This is the low-level trait that is designed for being as general as possible.
The ID
parameter to this trait exists so that a single type can provide multiple
implementations of this trait. For example, if a struct has multiple work_struct
fields, then
you will implement this trait once for each field, using a different id for each field. The
actual value of the id is not important as long as you use different ids for different fields
of the same struct. (Fields of different structs need not use different ids.)
Note that the id is used only to select the right method to call during compilation. It wont be part of the final executable.
Safety
Implementers must ensure that any pointers passed to a queue_work_on
closure by __enqueue
remain valid for the duration specified in the guarantees section of the documentation for
__enqueue
.
Required Associated Types§
sourcetype EnqueueOutput
type EnqueueOutput
The return type of Queue::enqueue
.
Required Methods§
sourceunsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutputwhere
F: FnOnce(*mut work_struct) -> bool,
unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutputwhere F: FnOnce(*mut work_struct) -> bool,
Enqueues this work item on a queue using the provided queue_work_on
method.
Guarantees
If this method calls the provided closure, then the raw pointer is guaranteed to point at a
valid work_struct
for the duration of the call to the closure. If the closure returns
true, then it is further guaranteed that the pointer remains valid until someone calls the
function pointer stored in the work_struct
.
Safety
The provided closure may only return false
if the work_struct
is already in a workqueue.
If the work item type is annotated with any lifetimes, then you must not call the function pointer after any such lifetime expires. (Never calling the function pointer is okay.)
If the work item type is not Send
, then the function pointer must be called on the same
thread as the call to __enqueue
.