pub struct ThreadToken<T: 'static>(/* private fields */);Expand description
Holds a value inside a thread-local storage.
Then, this token can be used to access the underlying value as long you are in the same thread that created it.
This is useful on the web, where you are always in the same thread, but you
need to pass some kind of non-Send value across Send boundries of Makepad.
Warning: Trying to read the value from a different thread will panic.
Warning: This token is reference counted so you can have copies of it, but the last copy must be dropped in the same thread that created it to avoid leaks. If this value is dropped in a different thread, it will panic.
Implementations§
Source§impl<T> ThreadToken<T>
impl<T> ThreadToken<T>
Source§impl<T: Clone> ThreadToken<T>
impl<T: Clone> ThreadToken<T>
Sourcepub fn clone_inner(&self) -> T
pub fn clone_inner(&self) -> T
Clone the associated value of this token and return it.
Trait Implementations§
Source§impl<T> Clone for ThreadToken<T>
impl<T> Clone for ThreadToken<T>
Auto Trait Implementations§
impl<T> Freeze for ThreadToken<T>
impl<T> RefUnwindSafe for ThreadToken<T>
impl<T> Send for ThreadToken<T>
impl<T> Sync for ThreadToken<T>
impl<T> Unpin for ThreadToken<T>
impl<T> UnwindSafe for ThreadToken<T>
Blanket Implementations§
§impl<T> ActionTrait for T
impl<T> ActionTrait for T
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