From 919940a5bf5d7a0e417b630a3e1b42b80516cdac Mon Sep 17 00:00:00 2001 From: ivanjermakov Date: Thu, 11 Apr 2024 04:13:39 +0200 Subject: [PATCH] Std: `delay` --- src/std/future.no | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/std/future.no b/src/std/future.no index 851c6fbd..84df01d5 100644 --- a/src/std/future.no +++ b/src/std/future.no @@ -81,6 +81,11 @@ impl Runtime { } } +// TODO: use std::time::Duration +pub fn delay(delay: Int): Future { + Future::new(|resolve| deferFor(|| resolve(unit), delay)) +} + pub fn defer(f: ||: Unit): Unit { deferFor(f, 0) }