Skip to content

Commit dfca6cb

Browse files
committed
replace sync.OnceFunc with sync.Once.Do
1 parent fcb3261 commit dfca6cb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

capture.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ func alert(exception error) error {
161161
defer timer.Stop()
162162

163163
done := make(chan struct{})
164-
finish := sync.OnceFunc(func() {close(done)})
164+
finish := func() {close(done)}
165+
var once sync.Once
165166
var mu sync.Mutex
166167

167168
// start a goroutine for each handler
@@ -185,7 +186,7 @@ func alert(exception error) error {
185186
default:
186187
e.id[provider] = id
187188
if len(e.id) == len(capture) {
188-
finish()
189+
once.Do(finish)
189190
}
190191
}
191192
}()
@@ -197,8 +198,8 @@ waitLoop:
197198
select {
198199
case <- timer.C:
199200
mu.Lock()
200-
defer mu.Unlock()
201-
finish()
201+
once.Do(finish)
202+
mu.Unlock()
202203
case <- done:
203204
break waitLoop
204205
}

0 commit comments

Comments
 (0)