pub struct LockClassKey { /* private fields */ }
Expand description
Represents a lockdep class. It’s a wrapper around C’s lock_class_key
.
Implementations§
Source§impl LockClassKey
impl 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.
§Example
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_str!("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 Sync for LockClassKey
Auto Trait Implementations§
impl !Freeze for LockClassKey
impl !RefUnwindSafe for LockClassKey
impl !Send 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
Mutably borrows from an owned value. Read more