TimerService.php 403 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace ln\services;
  3. use Swoole\Timer;
  4. use think\facade\Log;
  5. class TimerService
  6. {
  7. public function tick($limit, $fn)
  8. {
  9. Timer::tick($limit, function () use ($fn) {
  10. try {
  11. $fn();
  12. } catch (\Throwable $e) {
  13. Log::error('定时器报错[' . class_basename($this) . ']: ' . $e->getMessage());
  14. }
  15. });
  16. }
  17. }