Merge pull request #648 from aofei/sync

perf(lib/sync): avoid using `defer`
This commit is contained in:
xushiwei
2024-08-04 07:31:49 +08:00
committed by GitHub

View File

@@ -98,11 +98,11 @@ type Once struct {
func (o *Once) Do(f func()) {
if !o.done {
o.m.Lock()
defer o.m.Unlock()
if !o.done {
o.done = true
f()
}
o.m.Unlock()
}
}