aboutsummaryrefslogtreecommitdiffstats
path: root/src/signal.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-12-01 23:37:26 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-12-01 23:37:26 +0100
commiteaca1ee1f79422a501394415fd4ae8f227a134af (patch)
tree1fbfad20b2e9a6b68d5ccd928ed6678596de76b9 /src/signal.go
parentFixed receive path infinite loop (diff)
downloadwireguard-go-eaca1ee1f79422a501394415fd4ae8f227a134af.tar.xz
wireguard-go-eaca1ee1f79422a501394415fd4ae8f227a134af.zip
More consistent use of signal struct
Diffstat (limited to '')
-rw-r--r--src/signal.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/signal.go b/src/signal.go
index 96b21bb..2cefad4 100644
--- a/src/signal.go
+++ b/src/signal.go
@@ -20,6 +20,8 @@ func (s *Signal) Enable() {
s.enabled.Set(true)
}
+/* Unblock exactly one listener
+ */
func (s *Signal) Send() {
if s.enabled.Get() {
select {
@@ -29,6 +31,8 @@ func (s *Signal) Send() {
}
}
+/* Clear the signal if already fired
+ */
func (s Signal) Clear() {
select {
case <-s.C:
@@ -36,10 +40,14 @@ func (s Signal) Clear() {
}
}
+/* Unblocks all listeners (forever)
+ */
func (s Signal) Broadcast() {
- close(s.C) // unblocks all selectors
+ close(s.C)
}
+/* Wait for the signal
+ */
func (s Signal) Wait() chan struct{} {
return s.C
}