2022-06-17 11:59:19 +08:00
|
|
|
<?php
|
2023-04-16 01:45:34 +08:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2022-06-17 11:59:19 +08:00
|
|
|
|
|
|
|
|
namespace Kiri;
|
|
|
|
|
|
|
|
|
|
class Coordinator
|
|
|
|
|
{
|
|
|
|
|
|
2023-12-12 15:35:38 +08:00
|
|
|
const string WORKER_START = 'worker:start';
|
2022-06-17 11:59:19 +08:00
|
|
|
|
2024-11-15 14:24:19 +08:00
|
|
|
private bool $waite = true;
|
2022-06-17 11:59:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function yield(): void
|
|
|
|
|
{
|
|
|
|
|
if ($this->waite === false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->yield();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function waite(): void
|
|
|
|
|
{
|
|
|
|
|
$this->waite = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function done(): void
|
|
|
|
|
{
|
|
|
|
|
$this->waite = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|