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
Raw Normal View History

2015-03-18 19:04:18 +01:00
<?php
namespace Amp;
class Pause implements Promise {
use Placeholder;
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
}
}