ThreadError
pub enum ThreadError = { OutOfMemory, CreateFailed, JoinFailed, DetachFailed, AlreadyJoined }Variants
OutOfMemoryCreateFailedJoinFailedDetachFailedAlreadyJoined
pub enum ThreadError = { OutOfMemory, CreateFailed, JoinFailed, DetachFailed, AlreadyJoined }OutOfMemoryCreateFailedJoinFailedDetachFailedAlreadyJoinedfn alloc_in[A: allocators.GeneralAllocator](ac: A, size: usize) option[ref void]fn free_in[A: allocators.GeneralAllocator](ac: A, ptr: ref void) voidpub type Thread = { handle: ref void, joined: bool }Opaque thread handle — wraps pthread_t on POSIX, HANDLE on Windows.
| Name | Type |
|---|---|
handle | ref void |
joined | bool |
extern (C) fn pthread_create(thread: ref void, attr: ref void, start_routine: usize, arg: ref void) i32 = trust { ... } = "pthread_create"extern (C) fn pthread_join(thread: ref void, retval: ref void) i32 = trust { ... } = "pthread_join"extern (C) fn pthread_detach(thread: ref void) i32 = trust { ... } = "pthread_detach"extern (C) fn pthread_self() ref void = trust { ... } = "pthread_self"extern (C) fn sched_yield() i32 = trust { ... } = "sched_yield"extern (C) fn CreateThread(lpThreadAttributes: ref void, dwStackSize: usize, lpStartAddress: usize, lpParameter: ref void, dwCreationFlags: u32, lpThreadId: ref u32) ref void = trust { ... } = "CreateThread"extern (C) fn WaitForSingleObject(hHandle: ref void, dwMilliseconds: u32) u32 = trust { ... } = "WaitForSingleObject"extern (C) fn CloseHandle(hObject: ref void) i32 = trust { ... } = "CloseHandle"extern (C) fn GetCurrentThreadId() u32 = trust { ... } = "GetCurrentThreadId"extern (C) fn SwitchToThread() i32 = trust { ... } = "SwitchToThread"pub fn (Thread) new[A: allocators.GeneralAllocator](ac: A, entry: fn(ref void) ref void, arg: ref void) result[ref void, ThreadError]Create a new thread running `entry` with the given `arg`.
pub fn (Thread) join[A: allocators.GeneralAllocator](ac: A, thread: Thread) result[ref void, ThreadError]pub fn (Thread) detach[A: allocators.GeneralAllocator](ac: A, thread: Thread) result[void, ThreadError]pub fn (Thread) free[A: allocators.GeneralAllocator](ac: A, thread: mut Thread) voidpub fn current_thread_id() usizepub fn yield_thread() void = trust { ... }pub type Mutex = { ptr: ref void }| Name | Type |
|---|---|
ptr | ref void |
extern (C) fn pthread_mutex_init(mutex: ref void, attr: ref void) i32 = trust { ... } = "pthread_mutex_init"extern (C) fn pthread_mutex_destroy(mutex: ref void) i32 = trust { ... } = "pthread_mutex_destroy"extern (C) fn pthread_mutex_lock(mutex: ref void) i32 = trust { ... } = "pthread_mutex_lock"extern (C) fn pthread_mutex_unlock(mutex: ref void) i32 = trust { ... } = "pthread_mutex_unlock"extern (C) fn InitializeCriticalSection(lpCriticalSection: ref void) void = trust { ... } = "InitializeCriticalSection"extern (C) fn DeleteCriticalSection(lpCriticalSection: ref void) void = trust { ... } = "DeleteCriticalSection"extern (C) fn EnterCriticalSection(lpCriticalSection: ref void) void = trust { ... } = "EnterCriticalSection"extern (C) fn LeaveCriticalSection(lpCriticalSection: ref void) void = trust { ... } = "LeaveCriticalSection"pub fn (Mutex) new[A: allocators.GeneralAllocator](ac: A) option[ref void]pub fn (Mutex) lock(m: Mutex) voidpub fn (Mutex) unlock(m: Mutex) void = trust { ... }pub fn (Mutex) free[A: allocators.GeneralAllocator](ac: A, m: mut Mutex) voidfn thread_test_entry(arg: ref void) ref void