-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Sincerely ask, is this redundant? #2923
Copy link
Copy link
Closed
Description
Version:Latest, v1.43.2
Description:
func safeAsyncClose(b *Broker) {
tmp := b // local var prevents clobbering in goroutine
go withRecover(func() {
if connected, _ := tmp.Connected(); connected {
if err := tmp.Close(); err != nil {
Logger.Println("Error closing broker", tmp.ID(), ":", err)
}
}
})
}
annotation says "local var prevents clobbering in goroutine", how it works? I mean when safeAsyncClose is called, the local var b is just a copy pointing to the Broker, even if goroutine overwrites b, other goroutines will not perceive it.
thanks for help :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels