Struct kernel::utilities::static_init::UninitializedBuffer
source · [−]#[repr(transparent)]pub struct UninitializedBuffer<T>(_);
Expand description
The UninitializedBuffer
type is designed to be statically allocated
as a global buffer to hold data structures in Tock. As a static, global
buffer the data structure can then be shared in the Tock kernel.
This type is implemented as a wrapper around a MaybeUninit<T>
buffer.
To enforce that the global static buffer is initialized exactly once,
this wrapper type ensures that the underlying memory is uninitialized
so that an UninitializedBuffer
does not contain an initialized value.
The only way to initialize this buffer is to create a
StaticUninitializedBuffer
, pass the UninitializedBuffer
to it, and call
initialize()
. This structure ensures that:
-
The static buffer is not used while uninitialized. Since the only way to get the necessary
&'static mut T
is to callinitialize()
, the memory is guaranteed to be initialized. -
A static buffer is not initialized twice. Since the underlying memory is owned by
UninitializedBuffer
nothing else can initialize it. Also, once the memory is initialized viaStaticUninitializedBuffer.initialize()
, the internal buffer is consumed andinitialize()
cannot be called again.
Implementations
sourceimpl<T> UninitializedBuffer<T>
impl<T> UninitializedBuffer<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for UninitializedBuffer<T> where
T: RefUnwindSafe,
impl<T> Send for UninitializedBuffer<T> where
T: Send,
impl<T> Sync for UninitializedBuffer<T> where
T: Sync,
impl<T> Unpin for UninitializedBuffer<T> where
T: Unpin,
impl<T> UnwindSafe for UninitializedBuffer<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more