Defaulted concurrency level for concurrent collections

This commit is contained in:
RogueException
2016-10-05 02:26:15 -03:00
parent aa363fe058
commit 91154ba1d6
2 changed files with 4 additions and 4 deletions

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;

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>();
}