pub struct LockClassKey { /* private fields */ }Expand description
Represents a lockdep class.
Wraps the kernel’s struct lock_class_key.
Implementations§
Source§impl LockClassKey
impl LockClassKey
Sourcepub fn project<'__this>(self: Pin<&'__this mut Self>) -> __Projection<'__this>
pub fn project<'__this>(self: Pin<&'__this mut Self>) -> __Projection<'__this>
Pin-projects all fields of Self.
These fields are structurally pinned:
inner
These fields are not structurally pinned:
Sourcepub fn with_project<'__this, R>(
self: Pin<&'__this mut Self>,
f: impl FnOnce(__ProjectionLt<'__this>) -> R,
) -> R
pub fn with_project<'__this, R>( self: Pin<&'__this mut Self>, f: impl FnOnce(__ProjectionLt<'__this>) -> R, ) -> R
Pin-projects all fields of Self with proper lifetime.
These fields are structurally pinned:
inner
These fields are not structurally pinned:
Sourcepub fn with_project_ref<'__this, R>(
self: Pin<&'__this Self>,
f: impl FnOnce(__ProjectionRef<'__this>) -> R,
) -> R
pub fn with_project_ref<'__this, R>( self: Pin<&'__this Self>, f: impl FnOnce(__ProjectionRef<'__this>) -> R, ) -> R
Pin-projects all fields of Self from a shared reference with proper lifetime.
These fields are structurally pinned:
inner
These fields are not structurally pinned:
Source§impl LockClassKey
impl LockClassKey
Sourcepub const unsafe fn new_static() -> Self
pub const unsafe fn new_static() -> Self
Initializes a statically allocated lock class key.
This is usually used indirectly through the static_lock_class! macro. See its
documentation for more information.
§Safety
- Before using the returned value, it must be pinned in a static memory location.
- The destructor must never run on the returned
LockClassKey.
Sourcepub fn new_dynamic() -> impl PinInit<Self>
pub fn new_dynamic() -> impl PinInit<Self>
Initializes a dynamically allocated lock class key.
In the common case of using a statically allocated lock class key, the
static_lock_class! macro should be used instead.
§Examples
use kernel::alloc::KBox;
use kernel::types::ForeignOwnable;
use kernel::sync::{LockClassKey, SpinLock};
use pin_init::stack_pin_init;
let key = KBox::pin_init(LockClassKey::new_dynamic(), GFP_KERNEL)?;
let key_ptr = key.into_foreign();
{
stack_pin_init!(let num: SpinLock<u32> = SpinLock::new(
0,
c"my_spinlock",
// SAFETY: `key_ptr` is returned by the above `into_foreign()`, whose
// `from_foreign()` has not yet been called.
unsafe { <Pin<KBox<LockClassKey>> as ForeignOwnable>::borrow(key_ptr) }
));
}
// SAFETY: We dropped `num`, the only use of the key, so the result of the previous
// `borrow` has also been dropped. Thus, it's safe to use from_foreign.
unsafe { drop(<Pin<KBox<LockClassKey>> as ForeignOwnable>::from_foreign(key_ptr)) };Trait Implementations§
Source§impl Drop for LockClassKey
impl Drop for LockClassKey
Source§impl HasPinData for LockClassKey
impl HasPinData for LockClassKey
Source§impl PinnedDrop for LockClassKey
impl PinnedDrop for LockClassKey
impl Send for LockClassKey
impl Sync for LockClassKey
Auto Trait Implementations§
impl !Freeze for LockClassKey
impl !RefUnwindSafe for LockClassKey
impl !UnsafeUnpin for LockClassKey
impl UnwindSafe for LockClassKey
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
Source§fn into_safe_cast(self) -> T
fn into_safe_cast(self) -> T
self into a T. This operation is guaranteed to be lossless.Source§impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
Source§fn into_safe_cast_arch(self) -> T
fn into_safe_cast_arch(self) -> T
self into a T. This operation is guaranteed to be lossless.