mirror of
https://github.com/libp2p/go-eventbus.git
synced 2025-01-14 02:10:06 +08:00
Simplify withNode a bit
This commit is contained in:
parent
5b845983c2
commit
c54e8ebbe9
17
basic.go
17
basic.go
@ -36,19 +36,12 @@ func (b *bus) withNode(typ reflect.Type, cb func(*node), async func(*node)) erro
|
||||
n.lk.Lock()
|
||||
b.lk.Unlock()
|
||||
|
||||
ok = false
|
||||
defer func() {
|
||||
if !ok {
|
||||
n.lk.Unlock()
|
||||
}
|
||||
go func() {
|
||||
defer n.lk.Unlock()
|
||||
async(n)
|
||||
}()
|
||||
}()
|
||||
|
||||
cb(n)
|
||||
ok = true
|
||||
|
||||
go func() {
|
||||
defer n.lk.Unlock()
|
||||
async(n)
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user