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

21 lines
597 B
PHP
Raw Normal View History

2015-03-18 19:04:18 +01:00
<?php
namespace Amp;
2015-05-19 06:29:03 +02:00
class Pause extends PrivatePlaceholder {
2015-03-19 16:14:21 +01:00
public function __construct(int $millisecondTimeout, Reactor $reactor = null) {
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
}
}