github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/agent/ae/trigger.go (about) 1 package ae 2 3 // Trigger implements a non-blocking event notifier. Events can be 4 // triggered without blocking and notifications happen only when the 5 // previous event was consumed. 6 type Trigger struct { 7 ch chan struct{} 8 } 9 10 func NewTrigger() *Trigger { 11 return &Trigger{make(chan struct{}, 1)} 12 } 13 14 func (t Trigger) Trigger() { 15 select { 16 case t.ch <- struct{}{}: 17 default: 18 } 19 } 20 21 func (t Trigger) Notif() <-chan struct{} { 22 return t.ch 23 }