mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
improve package gtimer for times limitation
This commit is contained in:
parent
fc88001a8c
commit
8acb921ee3
@ -33,13 +33,13 @@ func (entry *Entry) Status() int {
|
||||
// Run runs the timer job asynchronously.
|
||||
func (entry *Entry) Run() {
|
||||
leftRunningTimes := entry.times.Add(-1)
|
||||
// Running times exceeding checks.
|
||||
if leftRunningTimes < 0 {
|
||||
entry.status.Set(StatusClosed)
|
||||
return
|
||||
}
|
||||
// This means it does not limit the running times.
|
||||
// I know it's ugly, but it is surely high performance for running times limit.
|
||||
if leftRunningTimes < 2000000000 && leftRunningTimes > 1000000000 {
|
||||
if leftRunningTimes == math.MaxInt32-1 {
|
||||
entry.times.Set(math.MaxInt32)
|
||||
}
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user