plat/win_thread.rs (Windows)#
Source: lib/plat/win_thread.rs
win_thread -- Windows threads, semaphores, the wake-up of the UI thread, system information
[src/plat/win/win_thread.s]
wake(): a flag coalesces bursts. With a window the wake-up is a posted WM_APP_WAKE (the
window turns it into E_WAKE, also inside modal loops); without one (headless, before the
window exists) an auto-reset event that wait_events waits for. Everything here is
thread safe.
struct Thread(isize)a thread started by thread_spawn; join it to wait for its endfn thread_spawn(stack: usize, f: Start) -> Option<Thread>run f on a new thread with stack bytes of stack (0 = 1 MB), committed up front [plat_thread_create]
impl Thread
fn join(self)wait until the thread has ended [plat_thread_join]fn thread_yield()give the rest of the time slice away [plat_thread_yield]struct Sem(isize)a counting semaphore
impl Sem
fn new(initial: u32) -> Option<Sem>fn post(&self, n: u32)add n units (0: nothing)fn wait(&self, ms: i32) -> booltake one unit: true taken, false timeout (ms -1 = forever, 0 = only try)fn wake()any thread: make the UI thread's wait return with E_WAKE (coalesced) [plat_wake]fn wait_events(deadline_us: u64, on_event: &mut dyn FnMut(&Event)) -> u32headless wait (no window): until a wake-up (E_WAKE to on_event, returns 1) or the deadline in time_us() (0 = only poll, u64::MAX = forever; returns 0) [plat_wait]fn cpu_count() -> u32logical processors this process may use (>= 1) [plat_cpu_count]fn mem_total() -> u64physical memory in bytes (0 unknown) [plat_mem_total]