mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 12:16:02 +08:00
Avoid some full memory barriers (#1590)
* Avoid some full memory barriers * Reset in stats itself * Updated MqttClientStatistics * Fixed order of members as artifact from merge-conflict
This commit is contained in:
@@ -22,7 +22,11 @@ namespace MQTTnet.Internal
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
#if NETCOREAPP3_1_OR_GREATER
|
||||
_queue.Clear();
|
||||
#else
|
||||
Interlocked.Exchange(ref _queue, new ConcurrentQueue<TItem>());
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -32,6 +36,16 @@ namespace MQTTnet.Internal
|
||||
_signal.Dispose();
|
||||
|
||||
_isDisposed = true;
|
||||
|
||||
#if !NETSTANDARD1_3
|
||||
if (typeof(IDisposable).IsAssignableFrom(typeof(TItem)))
|
||||
{
|
||||
while (_queue.TryDequeue(out TItem item))
|
||||
{
|
||||
(item as IDisposable).Dispose();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user