Changed various locking mechanism.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace HermesSocketServer.Socket.Handlers
|
||||
private readonly HashSet<string> _emotes;
|
||||
private readonly string[] _array;
|
||||
private readonly ILogger _logger;
|
||||
private readonly object _lock;
|
||||
private readonly Mutex _mutex;
|
||||
|
||||
private int _index;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace HermesSocketServer.Socket.Handlers
|
||||
_emotes = new HashSet<string>(EMOTE_BUFFER_SIZE);
|
||||
_array = new string[EMOTE_BUFFER_SIZE];
|
||||
_logger = logger;
|
||||
_lock = new object();
|
||||
_mutex = new Mutex();
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,9 @@ namespace HermesSocketServer.Socket.Handlers
|
||||
if (data.Emotes == null || !data.Emotes.Any())
|
||||
return;
|
||||
|
||||
lock (_lock)
|
||||
try
|
||||
{
|
||||
_mutex.WaitOne();
|
||||
foreach (var entry in data.Emotes)
|
||||
{
|
||||
if (_emotes.Contains(entry.Key))
|
||||
@@ -59,6 +60,10 @@ namespace HermesSocketServer.Socket.Handlers
|
||||
_array[_index] = entry.Key;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_mutex.ReleaseMutex();
|
||||
}
|
||||
|
||||
if (!data.Emotes.Any())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user