fun thread::sleep(Duration: number): nil
Causes the current thread to sleep for
fun thread(Args: any, ..., Fn: function): thread
Creates a new thread and calls
Fn(Args...)in the new thread. All arguments must be thread-safe.
meth (Thread: thread):join: any
Waits until the thread
Threadcompletes and returns its result.
A channel for thread communication.
fun thread::channel(Capacity: integer): thread::channel
Creates a new channel with capacity
meth (Channel₁: thread::channel):recv(: thread::channel, ...): tuple[integer, any]
Gets the next available message on any of
Channel₁, ..., Channelₙ, blocking if
Channelis empty. Returns
Index = 1, ..., n.
meth (Channel: thread::channel):send(Message: any): thread::channel
Messagemust be thread-safe. Blocks if
Channelis currently full.
fun thread::condition(): thread::condition
Creates a new condition.
meth (Condition: thread::condition):broadcast: thread::condition
Signals all threads waiting on
meth (Condition: thread::condition):signal: thread::condition
Signals a single thread waiting on
meth (Condition: thread::condition):wait(Mutex: thread::mutex): thread::condition
Waits for a signal on
fun thread::mutex(): thread::mutex
Creates a new mutex.
meth (Mutex: thread::mutex):lock: thread::mutex
meth (Mutex: thread::mutex):protect(Value: any): thread::protected
Creates a thread-safe (protected) wrapper for
meth (Mutex: thread::mutex):unlock: thread::mutex
A thread-safe (protected) wrapper for another value.
meth (Protected₁: thread::protected):use(: thread::protected, ..., Function: function): any
Protected₁:mutex, then calls
Function(Value₁, ..., Valueₙ)where
Valueᵢis the value protected by
Protectedᵢmust be protected by the same