Lines Matching defs:ID

7 //! One pattern that is used in both APIs is the `ID` const generic, which exists to allow a single
267 pub fn enqueue<W, const ID: u64>(&self, w: W) -> W::EnqueueOutput
269 W: RawWorkItem<ID> + Send + 'static,
300 pub fn enqueue_delayed<W, const ID: u64>(&self, w: W, delay: Jiffies) -> W::EnqueueOutput
302 W: RawDelayedWorkItem<ID> + Send + 'static,
373 /// The `ID` parameter to this trait exists so that a single type can provide multiple
389 pub unsafe trait RawWorkItem<const ID: u64> {
424 pub unsafe trait RawDelayedWorkItem<const ID: u64>: RawWorkItem<ID> {}
443 pub unsafe trait WorkItemPointer<const ID: u64>: RawWorkItem<ID> {
458 pub trait WorkItem<const ID: u64 = 0> {
461 type Pointer: WorkItemPointer<ID>;
479 pub struct Work<T: ?Sized, const ID: u64 = 0> {
488 unsafe impl<T: ?Sized, const ID: u64> Send for Work<T, ID> {}
492 unsafe impl<T: ?Sized, const ID: u64> Sync for Work<T, ID> {}
494 impl<T: ?Sized, const ID: u64> Work<T, ID> {
499 T: WorkItem<ID>,
535 /// Declares that a type contains a [`Work<T, ID>`].
560 /// - `raw_get_work(work_container_of(ptr)) == ptr` for any `ptr: *mut Work<T, ID>`.
565 pub unsafe trait HasWork<T, const ID: u64 = 0> {
566 /// Returns a pointer to the [`Work<T, ID>`] field.
571 unsafe fn raw_get_work(ptr: *mut Self) -> *mut Work<T, ID>;
573 /// Returns a pointer to the struct containing the [`Work<T, ID>`] field.
577 /// The pointer must point at a [`Work<T, ID>`] field in a struct of type `Self`.
578 unsafe fn work_container_of(ptr: *mut Work<T, ID>) -> *mut Self;
581 /// Used to safely implement the [`HasWork<T, ID>`] trait.
647 pub struct DelayedWork<T: ?Sized, const ID: u64 = 0> {
656 unsafe impl<T: ?Sized, const ID: u64> Send for DelayedWork<T, ID> {}
660 unsafe impl<T: ?Sized, const ID: u64> Sync for DelayedWork<T, ID> {}
662 impl<T: ?Sized, const ID: u64> DelayedWork<T, ID> {
672 T: WorkItem<ID>,
712 pub unsafe fn raw_as_work(ptr: *const Self) -> *mut Work<T, ID> {
723 /// Declares that a type contains a [`DelayedWork<T, ID>`].
727 /// The `HasWork<T, ID>` implementation must return a `work_struct` that is stored in the `work`
729 pub unsafe trait HasDelayedWork<T, const ID: u64 = 0>: HasWork<T, ID> {}
731 /// Used to safely implement the [`HasDelayedWork<T, ID>`] trait.
812 // will be used because of the ID const generic bound. This makes sure that `T::raw_get_work`
815 unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Arc<T>
817 T: WorkItem<ID, Pointer = Self>,
818 T: HasWork<T, ID>,
821 // The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
822 let ptr = ptr.cast::<Work<T, ID>>();
839 unsafe impl<T, const ID: u64> RawWorkItem<ID> for Arc<T>
841 T: WorkItem<ID, Pointer = Self>,
842 T: HasWork<T, ID>,
870 unsafe impl<T, const ID: u64> RawDelayedWorkItem<ID> for Arc<T>
872 T: WorkItem<ID, Pointer = Self>,
873 T: HasDelayedWork<T, ID>,
878 unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Pin<KBox<T>>
880 T: WorkItem<ID, Pointer = Self>,
881 T: HasWork<T, ID>,
884 // The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
885 let ptr = ptr.cast::<Work<T, ID>>();
898 unsafe impl<T, const ID: u64> RawWorkItem<ID> for Pin<KBox<T>>
900 T: WorkItem<ID, Pointer = Self>,
901 T: HasWork<T, ID>,
930 unsafe impl<T, const ID: u64> RawDelayedWorkItem<ID> for Pin<KBox<T>>
932 T: WorkItem<ID, Pointer = Self>,
933 T: HasDelayedWork<T, ID>,