1234567891011121314151617181920212223 |
- <?php
- namespace ln\services;
- use Swoole\Timer;
- use think\facade\Log;
- class TimerService
- {
- public function tick($limit, $fn)
- {
- Timer::tick($limit, function () use ($fn) {
- try {
- $fn();
- } catch (\Throwable $e) {
- Log::error('定时器报错[' . class_basename($this) . ']: ' . $e->getMessage());
- }
- });
- }
- }
|