diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-12-01 23:37:26 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-12-01 23:37:26 +0100 |
commit | eaca1ee1f79422a501394415fd4ae8f227a134af (patch) | |
tree | 1fbfad20b2e9a6b68d5ccd928ed6678596de76b9 /src/misc.go | |
parent | cb09125dc4c64360697af700ba71331d91e9edcd (diff) | |
download | wireguard-go-eaca1ee1f79422a501394415fd4ae8f227a134af.tar.gz wireguard-go-eaca1ee1f79422a501394415fd4ae8f227a134af.zip |
More consistent use of signal struct
Diffstat (limited to 'src/misc.go')
-rw-r--r-- | src/misc.go | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/src/misc.go b/src/misc.go index b43e97e..80e33f6 100644 --- a/src/misc.go +++ b/src/misc.go @@ -2,12 +2,10 @@ package main import ( "sync/atomic" - "time" ) -/* We use int32 as atomic bools - * (since booleans are not natively supported by sync/atomic) - */ +/* Atomic Boolean */ + const ( AtomicFalse = int32(iota) AtomicTrue @@ -37,6 +35,8 @@ func (a *AtomicBool) Set(val bool) { atomic.StoreInt32(&a.flag, flag) } +/* Integer manipulation */ + func toInt32(n uint32) int32 { mask := uint32(1 << 31) return int32(-(n & mask) + (n & ^mask)) @@ -55,32 +55,3 @@ func minUint64(a uint64, b uint64) uint64 { } return a } - -func signalSend(c chan struct{}) { - select { - case c <- struct{}{}: - default: - } -} - -func signalClear(c chan struct{}) { - select { - case <-c: - default: - } -} - -func timerStop(timer *time.Timer) { - if !timer.Stop() { - select { - case <-timer.C: - default: - } - } -} - -func NewStoppedTimer() *time.Timer { - timer := time.NewTimer(time.Hour) - timerStop(timer) - return timer -} |