From 5843974562500dfde9bc679aaf59f8cde0971fe7 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Wed, 27 Jul 2011 20:59:58 +0100 Subject: [PATCH] Make struct registry conform to EventRegistry. --- event/registry.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/event/registry.go b/event/registry.go index fd86889..68878ce 100644 --- a/event/registry.go +++ b/event/registry.go @@ -50,7 +50,7 @@ type registry struct { dispatcher func(r *registry, name string, ev ...interface{}) } -func NewRegistry() *registry { +func NewRegistry() EventRegistry { r := ®istry{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 }