Make struct registry conform to EventRegistry.

This commit is contained in:
Alex Bramley 2011-07-27 20:59:58 +01:00
parent 3e82bf33c3
commit 5843974562
1 changed files with 9 additions and 1 deletions

View File

@ -50,7 +50,7 @@ type registry struct {
dispatcher func(r *registry, name string, ev ...interface{})
}
func NewRegistry() *registry {
func NewRegistry() EventRegistry {
r := &registry{events: make(map[string]*list.List)}
r.Parallel()
return r
@ -89,6 +89,14 @@ func (r *registry) Dispatch(name string, ev ...interface{}) {
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() {
r.dispatcher = (*registry).parallelDispatch
}