mirror of https://github.com/fluffle/goirc
Make struct registry conform to EventRegistry.
This commit is contained in:
parent
3e82bf33c3
commit
5843974562
|
@ -50,7 +50,7 @@ type registry struct {
|
||||||
dispatcher func(r *registry, name string, ev ...interface{})
|
dispatcher func(r *registry, name string, ev ...interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRegistry() *registry {
|
func NewRegistry() EventRegistry {
|
||||||
r := ®istry{events: make(map[string]*list.List)}
|
r := ®istry{events: make(map[string]*list.List)}
|
||||||
r.Parallel()
|
r.Parallel()
|
||||||
return r
|
return r
|
||||||
|
@ -89,6 +89,14 @@ func (r *registry) Dispatch(name string, ev ...interface{}) {
|
||||||
r.dispatcher(r, name, ev...)
|
r.dispatcher(r, name, ev...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *registry) ClearEvents(name string) {
|
||||||
|
r.Lock()
|
||||||
|
defer r.Unlock()
|
||||||
|
if l, ok := r.events[name]; ok {
|
||||||
|
l.Init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *registry) Parallel() {
|
func (r *registry) Parallel() {
|
||||||
r.dispatcher = (*registry).parallelDispatch
|
r.dispatcher = (*registry).parallelDispatch
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue