Simplify withNode a bit

This commit is contained in:
Łukasz Magiera 2019-06-19 12:31:36 +02:00
parent 5b845983c2
commit c54e8ebbe9

View File

@ -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
}