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-20 00:49:08 +02:00
|
|
|
public function __construct($msTimeout, Reactor $reactor = null) {
|
|
|
|
if ($msTimeout < 1) {
|
|
|
|
throw new \DomainException(sprintf(
|
|
|
|
"Pause timeout must be greater than or equal to 1 millisecond; %d provided",
|
|
|
|
$msTimeout
|
|
|
|
));
|
2015-03-18 19:04:18 +01:00
|
|
|
}
|
2015-05-20 21:18:30 +02:00
|
|
|
$reactor = $reactor ?: reactor();
|
2015-05-20 00:49:08 +02:00
|
|
|
$reactor->once(function() { $this->resolve(); }, $msTimeout);
|
2015-03-18 19:04:18 +01:00
|
|
|
}
|
|
|
|
}
|