1
0
mirror of https://github.com/danog/amp.git synced 2024-12-14 02:17:26 +01:00
amp/lib/Pause.php

23 lines
607 B
PHP

<?php
namespace Amp;
class Pause implements Promise {
use Placeholder;
public function __construct($millisecondTimeout, Reactor $reactor = null) {
if ($millisecondTimeout < 1) {
throw new \DomainException(
sprintf(
"Pause millisecond timeout must be greater than or equal to 1; %d provided",
$millisecondTimeout
)
);
}
if (empty($reactor)) {
$reactor = getReactor();
}
$reactor->once(function() { $this->resolve(); }, $millisecondTimeout);
}
}