2016-05-23 00:44:35 -05:00
|
|
|
<?php
|
|
|
|
|
2016-05-23 22:48:28 -05:00
|
|
|
namespace Amp;
|
2016-05-23 00:44:35 -05:00
|
|
|
|
|
|
|
use Interop\Async\Awaitable;
|
|
|
|
use Interop\Async\Loop;
|
|
|
|
|
2016-06-01 12:18:11 -05:00
|
|
|
/**
|
|
|
|
* Creates an awaitable that resolves itself with a given value after a number of milliseconds.
|
|
|
|
*/
|
|
|
|
final class Pause implements Awaitable {
|
2016-05-23 00:44:35 -05:00
|
|
|
use Internal\Placeholder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $time Milliseconds before succeeding the awaitable.
|
|
|
|
* @param mixed $value Succeed the awaitable with this value.
|
|
|
|
*/
|
|
|
|
public function __construct($time, $value = null)
|
|
|
|
{
|
|
|
|
Loop::delay($time, function () use ($value) {
|
|
|
|
$this->resolve($value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|