OxL Справочник OxL
РусскийEnglish

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✓ проверяется в 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)

Потокобезопасность. the task belongs to the node, not to the caller's scope.

С версии. 1.0.0-beta

Параметры

ИмяТип
ffn() F

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/node.oxl:39

См. также