Functions.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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\Coordinator;
  12. /**
  13. * Block the current coroutine until the specified identifier is resumed.
  14. * Alias of `CoordinatorManager::until($identifier)->yield($timeout)`.
  15. */
  16. function block(float $timeout = -1, string $identifier = Constants::WORKER_EXIT): bool
  17. {
  18. return CoordinatorManager::until($identifier)->yield($timeout);
  19. }
  20. /**
  21. * Resume the coroutine that is blocked by the specified identifier.
  22. * Alias of `CoordinatorManager::until($identifier)->resume()`.
  23. */
  24. function resume(string $identifier = Constants::WORKER_EXIT): void
  25. {
  26. CoordinatorManager::until($identifier)->resume();
  27. }
  28. /**
  29. * Clear the coroutine that is blocked by the specified identifier.
  30. * Alias of `CoordinatorManager::clear($identifier)`.
  31. */
  32. function clear(string $identifier = Constants::WORKER_EXIT): void
  33. {
  34. CoordinatorManager::clear($identifier);
  35. }