From 49a154ebed22fef51fedd8f1e7937949caa6a2df Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 21 Aug 2020 12:04:35 -0400 Subject: [PATCH 1/2] fix: Removed the OnItemTrimmed event from the ScrollQueue due to deadlocks --- CHANGELOG.md | 3 ++ ICD.Common.Utils/Collections/ScrollQueue.cs | 33 ++++++++++----------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df3d699..cad2577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### 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 From aeba163a0f426f283b558c80691bb81f351ef202 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 21 Aug 2020 12:04:48 -0400 Subject: [PATCH 2/2] chore: Updating changelog, incrementing patch version --- CHANGELOG.md | 1 + ICD.Common.Utils/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cad2577..33d6dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [11.1.1] - 2020-08-21 ### Removed - Removed the OnItemTrimmed event from the ScrollQueue due to deadlocks diff --git a/ICD.Common.Utils/Properties/AssemblyInfo.cs b/ICD.Common.Utils/Properties/AssemblyInfo.cs index 49b916b..d63fa35 100644 --- a/ICD.Common.Utils/Properties/AssemblyInfo.cs +++ b/ICD.Common.Utils/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ using System.Reflection; [assembly: AssemblyCompany("ICD Systems")] [assembly: AssemblyProduct("ICD.Common.Utils")] [assembly: AssemblyCopyright("Copyright © ICD Systems 2020")] -[assembly: AssemblyVersion("11.1.0.0")] +[assembly: AssemblyVersion("11.1.1.0")]