@cryptotaxi247 / kubo / commits / d39feeb5a

notifier: go todo

Juan Batiz-Benet committed Jan 26, 2015 at 16:45 UTC d39feeb5a5f4a230475a870c03bac14d37df593b
1 file changed +5 -3
thirdparty/notifier/notifier.go
+5 -3
@@ -99,14 +99,16 @@ func (n *Notifier) StopNotify(e Notifiee) {
99 // })
100 // }
101 //
102 +// Note well: each notification is launched in its own goroutine, so they
103 +// can be processed concurrently, and so that whatever the notification does
104 +// it _never_ blocks out the client. This is so that consumers _cannot_ add
105 +// hooks into your object that block you accidentally.
106 func (n *Notifier) NotifyAll(notify func(Notifiee)) {
107 n.mu.Lock()
108 if n.nots != nil { // so that zero-value is ready to be used.
109 for notifiee := range n.nots {
106 - // we spin out a goroutine so that whatever the notification does
107 - // it _never_ blocks out the client. This is so that consumers
108 - // _cannot_ add hooks into your object that block you accidentally.
110 go notify(notifiee)
111 + // TODO find a good way to rate limit this without blocking notifier.
112 }
113 }
114 n.mu.Unlock()