2015-03-18 19:04:18 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp;
|
|
|
|
|
2015-05-19 20:10:53 +02:00
|
|
|
class Pause implements Promise {
|
|
|
|
use Placeholder;
|
|
|
|
|
2015-05-19 20:05:41 +02:00
|
|
|
public function __construct($millisecondTimeout, Reactor $reactor = null) {
|
2015-03-19 16:14:21 +01:00
|
|
|
if ($millisecondTimeout < 1) {
|
2015-03-18 19:04:18 +01:00
|
|
|
throw new \DomainException(
|
|
|
|
sprintf(
|
|
|
|
"Pause millisecond timeout must be greater than or equal to 1; %d provided",
|
2015-03-19 16:14:21 +01:00
|
|
|
$millisecondTimeout
|
2015-03-18 19:04:18 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (empty($reactor)) {
|
|
|
|
$reactor = getReactor();
|
|
|
|
}
|
2015-03-19 16:14:21 +01:00
|
|
|
$reactor->once(function() { $this->resolve(); }, $millisecondTimeout);
|
2015-03-18 19:04:18 +01:00
|
|
|
}
|
|
|
|
}
|