ProcessManager.php 971 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Process;
  12. use Hyperf\Contract\ProcessInterface;
  13. class ProcessManager
  14. {
  15. /**
  16. * @var array
  17. */
  18. protected static $processes = [];
  19. /**
  20. * @var bool
  21. */
  22. protected static $running = true;
  23. public static function register(ProcessInterface $process): void
  24. {
  25. static::$processes[] = $process;
  26. }
  27. public static function all(): array
  28. {
  29. return static::$processes;
  30. }
  31. public static function clear(): void
  32. {
  33. static::$processes = [];
  34. }
  35. public static function isRunning(): bool
  36. {
  37. return static::$running;
  38. }
  39. public static function setRunning(bool $running): void
  40. {
  41. static::$running = $running;
  42. }
  43. }