1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-17 19:19:11 -04:00

remove signal.Once

This commit is contained in:
Darien Raymond
2017-02-13 23:12:27 +01:00
parent 6d446f57f7
commit 90200fbecb
2 changed files with 14 additions and 38 deletions

View File

@@ -1,29 +0,0 @@
package signal
import (
"sync"
"sync/atomic"
)
type Once struct {
m sync.Mutex
done uint32
}
func (o *Once) Do(f func()) {
if atomic.LoadUint32(&o.done) == 1 {
return
}
o.m.Lock()
defer o.m.Unlock()
if o.done == 0 {
atomic.StoreUint32(&o.done, 1)
f()
}
}
func (o *Once) Reset() {
o.m.Lock()
defer o.m.Unlock()
atomic.StoreUint32(&o.done, 0)
}