File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 64
64
expFunc func (context.Context , string )
65
65
expFuncEnabled bool
66
66
expGroup singleflight.Group
67
- cancel context. CancelFunc
67
+ cancel atomic. Value
68
68
expire int64
69
69
l uint64
70
70
shards [slen ]* Map
@@ -170,7 +170,8 @@ func SetExpiredHook(f func(context.Context, string)) Gache {
170
170
func (g * gache ) StartExpired (ctx context.Context , dur time.Duration ) Gache {
171
171
go func () {
172
172
tick := time .NewTicker (dur )
173
- ctx , g .cancel = context .WithCancel (ctx )
173
+ ctx , cancel := context .WithCancel (ctx )
174
+ g .cancel .Store (cancel )
174
175
for {
175
176
select {
176
177
case <- ctx .Done ():
@@ -428,8 +429,8 @@ func Read(r io.Reader) error {
428
429
429
430
// Stop kills expire daemon
430
431
func (g * gache ) Stop () {
431
- if g . cancel != nil {
432
- g . cancel ()
432
+ if cancel := g . cancel . Load ().(context. CancelFunc ); cancel != nil {
433
+ cancel ()
433
434
}
434
435
}
435
436
You can’t perform that action at this time.
0 commit comments