event_synchronized.go 368 B

1234567891011121314151617181920212223242526
  1. package missinggo
  2. import "sync"
  3. type SynchronizedEvent struct {
  4. mu sync.Mutex
  5. e Event
  6. }
  7. func (me *SynchronizedEvent) Set() {
  8. me.mu.Lock()
  9. me.e.Set()
  10. me.mu.Unlock()
  11. }
  12. func (me *SynchronizedEvent) Clear() {
  13. me.mu.Lock()
  14. me.e.Clear()
  15. me.mu.Unlock()
  16. }
  17. func (me *SynchronizedEvent) C() <-chan struct{} {
  18. me.mu.Lock()
  19. defer me.mu.Unlock()
  20. return me.e.C()
  21. }