<thread> Internal Library
The <thread> module provides baseline parallel task execution and queue channels.
Import
import thr "<thread>"
Metadata
name:"thread"available: runtime support flagplatform:"windows"on Windows builds, otherwise"stub"version: internal module version string
API
spawn_native(job_name, ...args) -> intjoin(task_id, timeout_ms?) -> anyis_done(task_id) -> boolsleep(ms) -> boolyield() -> boolcpu_count() -> int
Channels
channel_create(capacity?) -> intchannel_send(channel_id, value) -> boolchannel_recv(channel_id, timeout_ms?) -> any | nonechannel_size(channel_id) -> int
Baseline Pool Aliases
pool_submit(job_name, ...args) -> intpool_join(task_id, timeout_ms?) -> any
Current baseline pool APIs map to the same task backend as spawn_native and join.
Built-in Jobs
sum: sums numeric argumentssleep_ms: sleeps and returnstrueecho: returns first argument
Example
import thr "<thread>"
var ch = thr.channel_create(4)
thr.channel_send(ch, 42)
display(thr.channel_recv(ch))
var id = thr.pool_submit("sum", 1, 2, 3)
display(thr.pool_join(id, 2000)) ## 6