mirror of
https://github.com/danog/asyncConstruct.git
synced 2024-12-02 09:17:48 +01:00
25 lines
425 B
PHP
25 lines
425 B
PHP
|
<?php
|
||
|
|
||
|
namespace danog\Test\Fixtures;
|
||
|
|
||
|
use danog\BlockingWakeup;
|
||
|
|
||
|
use function Amp\delay;
|
||
|
|
||
|
class BlockingWakeupTest
|
||
|
{
|
||
|
use BlockingWakeup;
|
||
|
public $woke = false;
|
||
|
private $delay;
|
||
|
public function __construct(int $delay)
|
||
|
{
|
||
|
$this->delay = $delay;
|
||
|
}
|
||
|
protected function __wakeup_async(): \Generator
|
||
|
{
|
||
|
yield delay($this->delay);
|
||
|
$this->woke = true;
|
||
|
return true;
|
||
|
}
|
||
|
}
|