More consistent use of signal struct
This commit is contained in:
parent
cb09125dc4
commit
eaca1ee1f7
9 changed files with 68 additions and 68 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue