Merge pull request #105 from rakyll/notifier-docs
Clarify chanotify docs about the usage of Add and Close
This commit is contained in:
commit
55c69b240f
1 changed files with 4 additions and 2 deletions
|
@ -19,7 +19,8 @@ type Notifier struct {
|
||||||
closed bool
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new *Notifier.
|
// New returns a new notifier. A notifier must be closed by
|
||||||
|
// calling, (*Notifier).Close, once it is no longer in use.
|
||||||
func New() *Notifier {
|
func New() *Notifier {
|
||||||
s := &Notifier{
|
s := &Notifier{
|
||||||
c: make(chan interface{}),
|
c: make(chan interface{}),
|
||||||
|
@ -34,7 +35,8 @@ func (n *Notifier) Chan() <-chan interface{} {
|
||||||
return n.c
|
return n.c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add adds new notification channel to Notifier.
|
// Add adds new notification channel to the notifier.
|
||||||
|
// Multiple registrations of the same ID is not allowed.
|
||||||
func (n *Notifier) Add(id interface{}, ch <-chan struct{}) error {
|
func (n *Notifier) Add(id interface{}, ch <-chan struct{}) error {
|
||||||
n.m.Lock()
|
n.m.Lock()
|
||||||
defer n.m.Unlock()
|
defer n.m.Unlock()
|
||||||
|
|
Loading…
Reference in a new issue