mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 02:10:46 +00:00
Co-authored-by: Boqin Qin <Bobbqqin@gmail.com>
This commit is contained in:
parent
27354ec059
commit
219e59dc4f
1 changed files with 3 additions and 3 deletions
|
|
@ -104,6 +104,7 @@ func (mux *TypeMux) Post(ev interface{}) error {
|
||||||
// Stop blocks until all current deliveries have finished.
|
// Stop blocks until all current deliveries have finished.
|
||||||
func (mux *TypeMux) Stop() {
|
func (mux *TypeMux) Stop() {
|
||||||
mux.mutex.Lock()
|
mux.mutex.Lock()
|
||||||
|
defer mux.mutex.Unlock()
|
||||||
for _, subs := range mux.subm {
|
for _, subs := range mux.subm {
|
||||||
for _, sub := range subs {
|
for _, sub := range subs {
|
||||||
sub.closewait()
|
sub.closewait()
|
||||||
|
|
@ -111,11 +112,11 @@ func (mux *TypeMux) Stop() {
|
||||||
}
|
}
|
||||||
mux.subm = nil
|
mux.subm = nil
|
||||||
mux.stopped = true
|
mux.stopped = true
|
||||||
mux.mutex.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mux *TypeMux) del(s *TypeMuxSubscription) {
|
func (mux *TypeMux) del(s *TypeMuxSubscription) {
|
||||||
mux.mutex.Lock()
|
mux.mutex.Lock()
|
||||||
|
defer mux.mutex.Unlock()
|
||||||
for typ, subs := range mux.subm {
|
for typ, subs := range mux.subm {
|
||||||
if pos := find(subs, s); pos >= 0 {
|
if pos := find(subs, s); pos >= 0 {
|
||||||
if len(subs) == 1 {
|
if len(subs) == 1 {
|
||||||
|
|
@ -125,7 +126,6 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.mux.mutex.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
|
func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
|
||||||
|
|
@ -196,9 +196,9 @@ func (s *TypeMuxSubscription) closewait() {
|
||||||
s.closed = true
|
s.closed = true
|
||||||
|
|
||||||
s.postMu.Lock()
|
s.postMu.Lock()
|
||||||
|
defer s.postMu.Unlock()
|
||||||
close(s.postC)
|
close(s.postC)
|
||||||
s.postC = nil
|
s.postC = nil
|
||||||
s.postMu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {
|
func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue