ReviewOS

home-lang/home

feat(lang): `spawn`, threads and a multi-core executor in the Home language

#805
Open chris opened this 8 days ago ·
8 days ago

Problem

Home code has no way to run in parallel. The lexer has no spawn keyword. packages/threading/src/bindings/sync.home (983 lines) declares @extern fn thread_spawn/mutex_create/..., but nothing exports those symbols. The interpreter's WorkerPool.spawn runs closures synchronously, and awaiting a pending future quietly returns Void. Native codegen says "We don't yet have an executor" — block_on busy-polls. examples/wip/async_example.home already uses spawn / Mutex<T>. (New direction.)

Evidence (origin/main @ d4b219507)

Scope

  • Language: spawn (thread) and task spawning on a multi-core executor; JoinHandle, scoped threads.
  • Export the sync.home extern symbols from the runtime (Mutex, CondVar, channels, Arc).
  • Interpreter: real threads; awaiting a pending future blocks or errors, never returns Void.
  • Native: a real executor instead of busy-poll block_on.

Acceptance criteria

  • A parallel sum in .home over 8 threads is ≥4× faster than single-threaded on native and interpreter builds.
  • examples/wip/async_example.home moves out of wip/ and runs.

Depends on: #802, #804, #807 Part of #814.

Sign in to comment on this issue.