8.16.0.2
15.1 Threads
A thread is a concurrent thread of evaluation. Rhombus schedules threads preemptively, but conceptually on the same physical processor; that is, threads provide concurrency, but not parallelism. Threads can communicate via shared state, and they can synchronize using semaphores or other synchronizable events.
A Thread object is itself a synchornizable event that is ready for synchronization when the thread has terminated. The synchronization result is just the thread object itself.
class | |||
| |||
| |||
expression | |||
|
The Thread class represents a thread. The
Thread constructor accepts a function to call in a newly
created thread. A thread: body; ... form is equivalent to
Thread(fun (): body; ...).
A Thread object satisfies Evt and includes the Evt.sync method.
Blocks until the thread th terminates.
Asynchronously raises an Exn.Break exception in
th, assuming that it has not yet terminated. If kind
is #'hang_up or #'terminate, then the exception is
more specifically Exn.Break.HangUp or
Exn.Break.Terminate, respectively.
Terminates the thread th. If the thread has already
terminated, then Thread.kill has no effect.
The Thread.handle property accesses a thread object’s
underlying Racket representation. The Thread.from_handle
function constructs a Rhombus thread object from a Racket thread object.
function | |
|
Causes the current thread to pause for at least secs seconds.