Skip to content

Commit

Permalink
修复偶尔会出现 Warning: swoole_timer_after(): Timer must be greater than 0 的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
breath-co2 committed Mar 20, 2017
1 parent 18c991e commit e90c3be
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/WorkerTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,17 @@ protected function timeTick($interval, $callback, $params = null)
$aTime += $interval * ceil($mTime / $interval) - $mTime;

# 增加一个延迟执行的定时器
swoole_timer_after($aTime, function() use ($interval, $callback, $params)
if ($aTime > 0)
{
swoole_timer_after($aTime, function() use ($interval, $callback, $params)
{
# 添加定时器
swoole_timer_tick($interval, $callback, $params);
});
}
else
{
# 添加定时器
swoole_timer_tick($interval, $callback, $params);
});
}
}
}

0 comments on commit e90c3be

Please sign in to comment.