Is len(map) threadsafe? (#3535)

This commit is contained in:
Preston Van Loon 2019-09-20 11:05:08 -07:00 committed by Raul Jordan
parent 9fcc6fc201
commit 37596ac188

View File

@ -35,6 +35,8 @@ func Delete(pid peer.ID) {
// Count of peer statuses in cache. Threadsafe. // Count of peer statuses in cache. Threadsafe.
func Count() int { func Count() int {
lock.RLock()
defer lock.RUnlock()
return len(peerStatuses) return len(peerStatuses)
} }