OxL Reference

method NodeBackground.spawn

Starts f as a background task of the node. A node with a live background task does not exit after main (§2.4 step 7): it runs until SIGTERM / SIGINT and drains.

Example:

oxl✓ checked in CI
fn main() io, time {
  node.background.spawn(() => {
    loop {
      sleep(1s)
      print("tick")
    }
  })
  print("main continues; the node stays up until SIGTERM")
}
pub(api) fn spawn<effect F>(f: fn() F)

Thread safety. the task belongs to the node, not to the caller's scope.

Since. 1.0.0-beta

Parameters

NameType
ffn() F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/node.oxl:39

See also