Browse Source

Simplify withNode a bit

pull/1681/head
Łukasz Magiera 5 years ago
parent
commit
e8cf02cfdf
  1. 17
      p2p/host/eventbus/basic.go

17
p2p/host/eventbus/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…
Cancel
Save