Struct wayland_commons::ThreadGuard
source · [−]pub struct ThreadGuard<T: ?Sized> { /* private fields */ }
Expand description
Stores a value in a threadafe container that only lets you access it from its owning thread
If the ThreadGuard is dropped from the wrong thread, the underlying value will be leaked.
Implementations
sourceimpl<T> ThreadGuard<T>
impl<T> ThreadGuard<T>
sourcepub fn new(val: T) -> ThreadGuard<T>
pub fn new(val: T) -> ThreadGuard<T>
Create a new ThreadGuard wrapper
sourceimpl<T: ?Sized> ThreadGuard<T>
impl<T: ?Sized> ThreadGuard<T>
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Mutably access the underlying value
Panics if done on the wrong thread
sourcepub fn try_get(&self) -> Option<&T>
pub fn try_get(&self) -> Option<&T>
Try to access the underlying value
Returns None
if done on the wrong thread
sourcepub fn try_get_mut(&mut self) -> Option<&mut T>
pub fn try_get_mut(&mut self) -> Option<&mut T>
Try to mutably access the underlying value
Returns None
if done on the wrong thread
Trait Implementations
sourceimpl<T: Debug + ?Sized> Debug for ThreadGuard<T>
impl<T: Debug + ?Sized> Debug for ThreadGuard<T>
sourceimpl<T: ?Sized> Drop for ThreadGuard<T>
impl<T: ?Sized> Drop for ThreadGuard<T>
impl<T: ?Sized> Send for ThreadGuard<T>
impl<T: ?Sized> Sync for ThreadGuard<T>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ThreadGuard<T> where
T: RefUnwindSafe,
impl<T: ?Sized> Unpin for ThreadGuard<T> where
T: Unpin,
impl<T: ?Sized> UnwindSafe for ThreadGuard<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