diff --git a/CHANGELOG.md b/CHANGELOG.md index 52b9ced..2acfdb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a bug where IcdCultureInfo would fail to load on Crestron 4-series processors - Clarifying which culture failed to load when IcdCultureInfo throws an exception +## [11.1.1] - 2020-08-21 +### Removed + - Removed the OnItemTrimmed event from the ScrollQueue due to deadlocks + ## [11.1.0] - 2020-05-19 ### Added - ScrollQueue - Added OnItemTrimmed event diff --git a/ICD.Common.Utils/Collections/ScrollQueue.cs b/ICD.Common.Utils/Collections/ScrollQueue.cs index eb636c5..5b28acd 100644 --- a/ICD.Common.Utils/Collections/ScrollQueue.cs +++ b/ICD.Common.Utils/Collections/ScrollQueue.cs @@ -2,8 +2,6 @@ using System.Collections; using System.Collections.Generic; using ICD.Common.Properties; -using ICD.Common.Utils.EventArguments; -using ICD.Common.Utils.Extensions; namespace ICD.Common.Utils.Collections { @@ -17,11 +15,6 @@ namespace ICD.Common.Utils.Collections private readonly LinkedList m_Collection; private int m_MaxSize; - /// - /// Raised when an item is trimmed from the end of the queue. - /// - public event EventHandler> OnItemTrimmed; - #region Properties /// @@ -38,7 +31,8 @@ namespace ICD.Common.Utils.Collections m_MaxSize = value; - Trim(); + TContents unused; + Trim(out unused); } } @@ -86,11 +80,13 @@ namespace ICD.Common.Utils.Collections /// Appends the item to the queue, trims old items that exceed max length. /// /// + /// + /// Returns true if an item was dequeued. [PublicAPI] - public void Enqueue(TContents item) + public bool Enqueue(TContents item, out TContents removed) { m_Collection.AddLast(item); - Trim(); + return Trim(out removed); } /// @@ -145,14 +141,17 @@ namespace ICD.Common.Utils.Collections /// /// Removes items that fall outside of the max size. /// - private void Trim() + private bool Trim(out TContents removed) { - while (Count > MaxSize) - { - TContents removed = m_Collection.First.Value; - m_Collection.RemoveFirst(); - OnItemTrimmed.Raise(this, new GenericEventArgs(removed)); - } + removed = default(TContents); + + if (Count <= MaxSize) + return false; + + removed = m_Collection.First.Value; + m_Collection.RemoveFirst(); + + return true; } #endregion