1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 10:28:01 +01:00
amp/lib/Pause.php
2016-08-17 22:25:54 -05:00

23 lines
588 B
PHP

<?php declare(strict_types = 1);
namespace Amp;
use Interop\Async\{ Awaitable, Loop };
/**
* Creates an awaitable that resolves itself with a given value after a number of milliseconds.
*/
final class Pause implements Awaitable {
use Internal\Placeholder;
/**
* @param int $time Milliseconds before succeeding the awaitable.
* @param mixed $value Succeed the awaitable with this value.
*/
public function __construct(int $time, $value = null) {
Loop::delay($time, function () use ($value) {
$this->resolve($value);
});
}
}