func NewMultiNotifyWatcher(w ...NotifyWatcher) *MultiNotifyWatcher {
	m := &MultiNotifyWatcher{
		watchers: w,
		changes:  make(chan struct{}),
	}
	var wg sync.WaitGroup
	wg.Add(len(w))
	staging := make(chan struct{})
	for _, w := range w {
		// Consume the first event of each watcher.
		<-w.Changes()
		go func(wCopy NotifyWatcher) {
			defer wg.Done()
			_ = wCopy.Wait()
		}(w)
		// Copy events from the watcher to the staging channel.
		go copyEvents(staging, w.Changes(), &m.tomb)
	}
	m.tomb.Go(func() error {
		m.loop(staging)
		wg.Wait()
		return nil
	})
	return m
}
// NewMultiNotifyWatcher creates a NotifyWatcher that combines
// each of the NotifyWatchers passed in. Each watcher's initial
// event is consumed, and a single initial event is sent.
// Subsequent events are not coalesced.
NewMultiNotifyWatcher creates a NotifyWatcher that combines
each of the NotifyWatchers passed in. Each watcher's initial
event is consumed, and a single initial event is sent.
Subsequent events are not coalesced.
// NewMultiNotifyWatcher creates a NotifyWatcher that combines // each of the NotifyWatchers passed in . Each watcher ' s initial // event is consumed and a single initial event is sent . // Subsequent events are not coalesced .
func NewMultiNotifyWatcher(w ...NotifyWatcher) *MultiNotifyWatcher {
	m := &MultiNotifyWatcher{
		watchers: w,
		changes:  make(chan struct{}),
	}
	var wg sync.WaitGroup
	wg.Add(len(w))
	staging := make(chan struct{})
	for _, w := range w {
		<-w.Changes()
		go func(wCopy NotifyWatcher) {
			defer wg.Done()
			_ = wCopy.Wait()
		}(w)
		go copyEvents(staging, w.Changes(), &m.tomb)
	}
	m.tomb.Go(func() error {
		m.loop(staging)
		wg.Wait()
		return nil
	})
	return m
}
func NewMultiNotifyWatcher ( w ... NotifyWatcher ) * MultiNotifyWatcher { m := & MultiNotifyWatcher { watchers : w , changes : make ( chan struct { } ) , } var wg sync . WaitGroup wg . Add ( len ( w ) ) staging := make ( chan struct { } ) for _ , w := range w { <- w . Changes ( ) go func ( wCopy NotifyWatcher ) { defer wg . Done ( ) _ = wCopy . Wait ( ) } ( w ) go copyEvents ( staging , w . Changes ( ) , & m . tomb ) } m . tomb . Go ( func ( ) error { m . loop ( staging ) wg . Wait ( ) return nil } ) return m }
NewMultiNotifyWatcher creates a NotifyWatcher that combines
each of the NotifyWatchers passed in.
NewMultiNotifyWatcher creates a NotifyWatcher that combines each of the NotifyWatchers passed in .
// Consume the first event of each watcher. // Copy events from the watcher to the staging channel.