Skip to content

Commit

Permalink
does this prevent mutable.HashSet from having a negative size?
Browse files Browse the repository at this point in the history
I have a mutable set
private val connectedUserIds = collection.mutable.Set.empty[String]
and according to monitoring the size of that set is negative
mon.sets.users(connectedUserIds.size)
Negative histogram value: socket.remote.sets.users=-194

Now I'm not a CS expert, but I'm quite sure sets are not supposed to have negative sizes
  • Loading branch information
ornicar committed Sep 20, 2019
1 parent 79a6330 commit 90b196d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/socket/src/main/RemoteSocket.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ final class RemoteSocket(
case In.ConnectUser(userId) =>
bus.publish(lila.hub.actorApi.socket.remote.ConnectUser(userId), 'userActive)
connectedUserIds += userId
case In.DisconnectUsers(userIds) => connectedUserIds --= userIds
case In.DisconnectUsers(userIds) => userIds foreach { userId =>
connectedUserIds -= userId
}
case In.Watch(gameId) => watchedGameIds += gameId
case In.Unwatch(gameId) => watchedGameIds -= gameId
case In.NotifiedBatch(userIds) => notificationActor ! lila.hub.actorApi.notify.NotifiedBatch(userIds)
Expand Down

0 comments on commit 90b196d

Please sign in to comment.