Ship

Book · Concurrency

Concurrency

Draft

Run direct-style work in parent-owned fibers on one Ship runtime.

Ship functions stay direct-style even when their work suspends. Ordinary operations return ordinary values; spawn is the one form that starts concurrent work, and await waits through the operand's canonical behavior.

Every spawned fiber has one owner. Successful results may move reachable tasks to the receiving owner; unreturned work is interrupted and drained before parent resources are released. Handles may be aliased and collected without duplicating ownership.

Native and Browser programs use these same task, ownership, cancellation, cleanup, and one-shot semantics.

  • Tasks introduces spawn and await.

  • Signals defines the scheduler wakeup foundation.

  • Ownership defines child lifetime and cleanup.

  • Failure routes child errors through ordinary exn.

  • One-shot values coordinate fibers deterministically.

  • Timers park a fiber until a Clock deadline.

  • Retry schedules rerun failing work with typed delays.

  • Actors own state behind typed messages.

  • Timeouts race a function's body against a deadline.

    Local fibers share one cooperative event loop, and actors run on those fibers today. Ordinary spawn never becomes hidden shared-memory parallelism.