mirror of
https://github.com/danog/amp.git
synced 2024-12-04 10:28:01 +01:00
5651240615
Dropped strict-types due to spec requiring weak types in callbacks.
23 lines
550 B
PHP
23 lines
550 B
PHP
<?php
|
|
|
|
namespace Amp;
|
|
|
|
use Interop\Async\{ Loop, Promise };
|
|
|
|
/**
|
|
* Creates a promise that resolves itself with a given value after a number of milliseconds.
|
|
*/
|
|
final class Pause implements Promise {
|
|
use Internal\Placeholder;
|
|
|
|
/**
|
|
* @param int $time Milliseconds before succeeding the promise.
|
|
* @param mixed $value Succeed the promise with this value.
|
|
*/
|
|
public function __construct(int $time, $value = null) {
|
|
Loop::delay($time, function () use ($value) {
|
|
$this->resolve($value);
|
|
});
|
|
}
|
|
}
|