Browse Source

Defaulted concurrency level for concurrent collections

tags/1.0-rc
RogueException 8 years ago
parent
commit
91154ba1d6
2 changed files with 4 additions and 4 deletions
  1. +3
    -3
      src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs
  2. +1
    -1
      src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs

+ 3
- 3
src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs View File

@@ -34,8 +34,8 @@ namespace Discord.WebSocket
{
if (Discord.MessageCacheSize > 0)
_messages = new MessageCache(Discord, this);
_voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(1, 5);
_users = new ConcurrentDictionary<ulong, SocketGroupUser>(1, 5);
_voiceStates = new ConcurrentDictionary<ulong, SocketVoiceState>(ConcurrentHashSet.DefaultConcurrencyLevel, 5);
_users = new ConcurrentDictionary<ulong, SocketGroupUser>(ConcurrentHashSet.DefaultConcurrencyLevel, 5);
}
internal static SocketGroupChannel Create(DiscordSocketClient discord, ClientState state, Model model)
{
@@ -55,7 +55,7 @@ namespace Discord.WebSocket
}
internal virtual void UpdateUsers(ClientState state, UserModel[] models)
{
var users = new ConcurrentDictionary<ulong, SocketGroupUser>(1, (int)(models.Length * 1.05));
var users = new ConcurrentDictionary<ulong, SocketGroupUser>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(models.Length * 1.05));
for (int i = 0; i < models.Length; i++)
users[models[i].Id] = SocketGroupUser.Create(this, state, models[i]);
_users = users;


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Messages/MessageCache.cs View File

@@ -17,7 +17,7 @@ namespace Discord.WebSocket
public MessageCache(DiscordSocketClient discord, IChannel channel)
{
_size = discord.MessageCacheSize;
_messages = new ConcurrentDictionary<ulong, SocketMessage>(1, (int)(_size * 1.05));
_messages = new ConcurrentDictionary<ulong, SocketMessage>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(_size * 1.05));
_orderedMessages = new ConcurrentQueue<ulong>();
}



Loading…
Cancel
Save