package core.thread
Thread :: struct {
id: i32;
alive: bool;
}
Represents a thread. Currently, this is very simple; just the id of the thread and whether or not it is alive.
__exited :: (id: i32) -> void
Special procedure that is called when a thread exits, or by kill() above.
__initialize :: () -> void
Special procedure that should only be called once globally that initialize the map of thread ids to thread data.
join :: (t: &Thread) -> void
Waits for a thread to finish before returning. If the thread was not alive in the first place, immediately return.
kill :: (t: &Thread) -> i32
Forcefully kill a thread using runtime.__kill_thread. Does nothing if the thread was not alive.
spawn :: (t: &Thread, data: &$T, func: (&T) -> void) -> void
Spawns a new thread using the runtime.__spawn_thread function. The primary job of this function is to create the thread-local storage and stack for the new thread, and pass those on. Currently the stack size is not controllable, but that could be remedied.