InitSwooleLockListen.php 436 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace ln\listens;
  3. use ln\interfaces\ListenerInterface;
  4. use Swoole\Lock;
  5. class InitSwooleLockListen implements ListenerInterface
  6. {
  7. public function handle($event): void
  8. {
  9. $GLOBALS['_swoole_order_lock'] = [];
  10. $locks = array_merge(['default'], config('swoole.locks'));
  11. foreach ($locks as $lock) {
  12. $GLOBALS['_swoole_order_lock'][$lock] = new Lock(SWOOLE_MUTEX);
  13. }
  14. }
  15. }