System & I/O4 exports
Raw Markdown/thread
OS thread spawning, parallel execution, sleeping, and synchronization.
Functions & symbols#
await#
function
Blocks until the spawned OS thread completes and returns its result.
| Parameter | Type | Optional | Description |
|---|---|---|---|
handle | Thread-Future | required | Thread handle returned by `thread/spawn` |
Returns:
Any(let out (thread/await h))await-all#
function
Waits for all OS threads in `handles` and collects results in order.
| Parameter | Type | Optional | Description |
|---|---|---|---|
handles | Array | required | Array of Thread-Future handles |
Returns:
Any(let results (thread/await-all [h1 h2]))sleep#
function
Sleeps the current OS thread for `duration-ms` milliseconds.
| Parameter | Type | Optional | Description |
|---|---|---|---|
duration_ms | Int | Float | required | Milliseconds to sleep |
Returns:
Any(thread/sleep 250)spawn#
function
Spawns an OS thread running `func` and returns a `Thread-Future` handle.
| Parameter | Type | Optional | Description |
|---|---|---|---|
func | Func | required | Zero-argument closure to run on a dedicated OS thread |
Returns:
Any(let h (thread/spawn (Func () (heavy-compute))))