From c6a775a6c9fdd9ca4c909647a19b02d2d11a0568 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 2 Aug 2019 22:37:42 +0200 Subject: [PATCH] Add delay function (#278) --- lib/functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/functions.php b/lib/functions.php index 6bb7108d..03223cec 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -90,6 +90,18 @@ function asyncCall(callable $callback, ...$args) { Promise\rethrow(call($callback, ...$args)); } + + /** + * Sleeps for the specified number of milliseconds. + * + * @param int $milliseconds + * + * @return Delayed + */ + function delay(int $milliseconds): Promise + { + return new Delayed($milliseconds); + } } namespace Amp\Promise