Skip to content

Commit cadade6

Browse files
authored
Merge pull request #379 from panjf2000/dev
patch: v2.11.5
2 parents f7128db + 8a24625 commit cadade6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ants.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ type poolCommon struct {
191191
ticktockCtx context.Context
192192
stopTicktock context.CancelFunc
193193

194-
now atomic.Value
194+
now int64
195195

196196
options *Options
197197
}
@@ -303,7 +303,7 @@ func (p *poolCommon) ticktock() {
303303
break
304304
}
305305

306-
p.now.Store(time.Now())
306+
atomic.StoreInt64(&p.now, time.Now().UnixNano())
307307
}
308308
}
309309

@@ -318,13 +318,13 @@ func (p *poolCommon) goPurge() {
318318
}
319319

320320
func (p *poolCommon) goTicktock() {
321-
p.now.Store(time.Now())
321+
atomic.StoreInt64(&p.now, time.Now().UnixNano())
322322
p.ticktockCtx, p.stopTicktock = context.WithCancel(context.Background())
323323
go p.ticktock()
324324
}
325325

326326
func (p *poolCommon) nowTime() time.Time {
327-
return p.now.Load().(time.Time)
327+
return time.Unix(0, atomic.LoadInt64(&p.now))
328328
}
329329

330330
// Running returns the number of workers currently running.

0 commit comments

Comments
 (0)