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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more