Struct glib::thread_guard::ThreadGuard
source · [−]pub struct ThreadGuard<T> { /* private fields */ }
Expand description
Thread guard that only gives access to the contained value on the thread it was created on.
Implementations
sourceimpl<T> ThreadGuard<T>
impl<T> ThreadGuard<T>
sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Create a new thread guard around value
.
The thread guard ensures that access to the value is only allowed from the thread it was created on, and otherwise panics.
The thread guard implements the Send
trait even if the contained value does not.
sourcepub fn get_ref(&self) -> &T
pub fn get_ref(&self) -> &T
Return a reference to the contained value from the thread guard.
Panics
This function panics if called from a different thread than where the thread guard was created.
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Return a mutable reference to the contained value from the thread guard.
Panics
This function panics if called from a different thread than where the thread guard was created.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Return the contained value from the thread guard.
Panics
This function panics if called from a different thread than where the thread guard was created.
Trait Implementations
sourceimpl<T> Drop for ThreadGuard<T>
impl<T> Drop for ThreadGuard<T>
impl<T> Send for ThreadGuard<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for ThreadGuard<T> where
T: RefUnwindSafe,
impl<T> Sync for ThreadGuard<T> where
T: Sync,
impl<T> Unpin for ThreadGuard<T> where
T: Unpin,
impl<T> 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