-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
I noticed a pattern that's a bit hard to understand:
cm.channelsMutex.Lock()
channel, exists = cm.channels[name]
cm.channelsMutex.Unlock()
if !exists {
// Ensure we update our cache of known channels
cm.channelsMutex.Lock()
defer cm.channelsMutex.Unlock()
channel, exists = cm.channels[name]
if exists {
return channel, nil
}
channel, err = cm.newChannel(name)
if err != nil {
return nil, err
}
cm.channels[name] = channel
}```
What is the work of the second `cm.channels[name]` if the first has exists false?
NB: getChannel function inside channel_manager.go file
Metadata
Metadata
Assignees
Labels
No labels