mirror of
https://github.com/danog/amp.git
synced 2024-12-14 18:37:30 +01:00
24 lines
581 B
PHP
24 lines
581 B
PHP
<?php
|
|
|
|
namespace Amp;
|
|
|
|
class Pause implements Promise {
|
|
use Placeholder;
|
|
|
|
/**
|
|
* @param int $timeout The timeout in milliseconds after which the promise will resolve
|
|
* @throws \DomainException On invalid timeout value
|
|
*/
|
|
public function __construct($timeout) {
|
|
$timeout = (int) $timeout;
|
|
if ($timeout < 1) {
|
|
throw new \DomainException(
|
|
"Pause timeout must be greater than or equal to 1 millisecond"
|
|
);
|
|
}
|
|
once(function () {
|
|
$this->resolve();
|
|
}, $timeout);
|
|
}
|
|
}
|