pub struct MainThreadToken(/* private fields */);Expand description
Zero sized token that can only exist on the main thread.
Call MainThreadToken::get() or MainThreadToken::assert() to get one.
As of sdl3-main 0.6, it’s not required to call MainThreadToken::init().
If SDL has been inited properly, only the thread that SDL considers the main thread
can get a MainThreadToken. Otherwise, the first call to either of MainThreadToken::get()
or MainThreadToken::assert() will determine which thread MainThreadToken considers
the main thread for the lifetime of the process. MainThreadToken::init() is equivalent
to MainThreadToken::assert() and is retained for backwards compatibility.
Implementations§
Source§impl MainThreadToken
impl MainThreadToken
Sourcepub fn get() -> Option<Self>
pub fn get() -> Option<Self>
Get Some(MainThreadToken) if called on the main thread, or None otherwise.
On targets that don’t support threads, this will always succeed.
See also MainThreadToken::assert()
Sourcepub fn assert() -> Self
pub fn assert() -> Self
Get MainThreadToken if called on the main thread, or panic otherwise.
On targets that don’t support threads, this will always succeed.
See also MainThreadToken::get()
Sourcepub unsafe fn init()
pub unsafe fn init()
Initialize MainThreadToken (if it wasn’t already) if called on the main thread,
or panic otherwise.
As of sdl3-main 0.6, this function is equivalent to MainThreadToken::assert().
On targets that don’t support threads, this will always succeed.
Trait Implementations§
Source§impl Clone for MainThreadToken
impl Clone for MainThreadToken
Source§fn clone(&self) -> MainThreadToken
fn clone(&self) -> MainThreadToken
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MainThreadToken
Auto Trait Implementations§
impl Freeze for MainThreadToken
impl RefUnwindSafe for MainThreadToken
impl !Send for MainThreadToken
impl !Sync for MainThreadToken
impl Unpin for MainThreadToken
impl UnwindSafe for MainThreadToken
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)