|
@@ -24,6 +24,7 @@ import (
|
|
|
type Wait interface {
|
|
type Wait interface {
|
|
|
Register(id uint64) <-chan interface{}
|
|
Register(id uint64) <-chan interface{}
|
|
|
Trigger(id uint64, x interface{})
|
|
Trigger(id uint64, x interface{})
|
|
|
|
|
+ IsRegistered(id uint64) bool
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type List struct {
|
|
type List struct {
|
|
@@ -59,6 +60,13 @@ func (w *List) Trigger(id uint64, x interface{}) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (w *List) IsRegistered(id uint64) bool {
|
|
|
|
|
+ w.l.Lock()
|
|
|
|
|
+ defer w.l.Unlock()
|
|
|
|
|
+ _, ok := w.m[id]
|
|
|
|
|
+ return ok
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
type waitWithResponse struct {
|
|
type waitWithResponse struct {
|
|
|
ch <-chan interface{}
|
|
ch <-chan interface{}
|
|
|
}
|
|
}
|
|
@@ -71,3 +79,6 @@ func (w *waitWithResponse) Register(id uint64) <-chan interface{} {
|
|
|
return w.ch
|
|
return w.ch
|
|
|
}
|
|
}
|
|
|
func (w *waitWithResponse) Trigger(id uint64, x interface{}) {}
|
|
func (w *waitWithResponse) Trigger(id uint64, x interface{}) {}
|
|
|
|
|
+func (w *waitWithResponse) IsRegistered(id uint64) bool {
|
|
|
|
|
+ panic("waitWithResponse.IsRegistered() shouldn't be called")
|
|
|
|
|
+}
|