Refactor removal from blocking queue.

This commit is contained in:
Christian Kratky
2018-11-23 22:56:10 +01:00
parent 40c408a9c0
commit 43105f71d8
2 changed files with 6 additions and 9 deletions
+4 -2
View File
@@ -77,11 +77,13 @@ namespace MQTTnet.Internal
}
}
public void RemoveFirstIfEqual(TItem item, Func<TItem, TItem, bool> areEqual)
public void RemoveFirst(Predicate<TItem> match)
{
if (match == null) throw new ArgumentNullException(nameof(match));
lock (_syncRoot)
{
if (_items.Count > 0 && areEqual(_items.First.Value, item))
if (_items.Count > 0 && match(_items.First.Value))
{
_items.RemoveFirst();
}