diff --git a/src/allocator.rs b/src/allocator.rs index 4b683208..a52744f4 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -54,3 +54,20 @@ unsafe impl GlobalAlloc for Dummy { panic!("dealloc should be never called") } } + +/// A wrapper around spin::Mutex to permit trait implementations. +pub struct Locked { + inner: spin::Mutex, +} + +impl Locked { + pub const fn new(inner: A) -> Self { + Locked { + inner: spin::Mutex::new(inner), + } + } + + pub fn lock(&self) -> spin::MutexGuard { + self.inner.lock() + } +}