Skip to content

Commit

Permalink
Add delay function (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
danog authored and kelunik committed Aug 2, 2019
1 parent b57fc2e commit c6a775a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6a775a

Please sign in to comment.