1
0
mirror of https://github.com/danog/amp.git synced 2024-12-14 10:27:58 +01:00
amp/lib/Pause.php
2015-03-18 14:05:27 -04:00

24 lines
615 B
PHP

<?php
namespace Amp;
class Pause extends Unresolved {
/**
* @TODO Add int $msTimeout typehint for PHP7
*/
public function __construct($msTimeout, Reactor $reactor = null) {
if ($msTimeout < 1) {
throw new \DomainException(
sprintf(
"Pause millisecond timeout must be greater than or equal to 1; %d provided",
$msTimeout
)
);
}
if (empty($reactor)) {
$reactor = getReactor();
}
$reactor->once(function() { $this->resolve(); }, $msTimeout);
}
}