mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Merge remote-tracking branch 'origin/ConnectPro_v1.6' into ConnectPro_v1.7
# Conflicts: # CHANGELOG.md # ICD.Common.Utils/Properties/AssemblyInfo.cs
This commit is contained in:
@@ -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
|
- 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
|
- 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
|
## [11.1.0] - 2020-05-19
|
||||||
### Added
|
### Added
|
||||||
- ScrollQueue - Added OnItemTrimmed event
|
- ScrollQueue - Added OnItemTrimmed event
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ICD.Common.Properties;
|
using ICD.Common.Properties;
|
||||||
using ICD.Common.Utils.EventArguments;
|
|
||||||
using ICD.Common.Utils.Extensions;
|
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Collections
|
namespace ICD.Common.Utils.Collections
|
||||||
{
|
{
|
||||||
@@ -17,11 +15,6 @@ namespace ICD.Common.Utils.Collections
|
|||||||
private readonly LinkedList<TContents> m_Collection;
|
private readonly LinkedList<TContents> m_Collection;
|
||||||
private int m_MaxSize;
|
private int m_MaxSize;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised when an item is trimmed from the end of the queue.
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<GenericEventArgs<TContents>> OnItemTrimmed;
|
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,7 +31,8 @@ namespace ICD.Common.Utils.Collections
|
|||||||
|
|
||||||
m_MaxSize = value;
|
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.
|
/// Appends the item to the queue, trims old items that exceed max length.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="removed"></param>
|
||||||
|
/// <returns>Returns true if an item was dequeued.</returns>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public void Enqueue(TContents item)
|
public bool Enqueue(TContents item, out TContents removed)
|
||||||
{
|
{
|
||||||
m_Collection.AddLast(item);
|
m_Collection.AddLast(item);
|
||||||
Trim();
|
return Trim(out removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -145,14 +141,17 @@ namespace ICD.Common.Utils.Collections
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes items that fall outside of the max size.
|
/// Removes items that fall outside of the max size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Trim()
|
private bool Trim(out TContents removed)
|
||||||
{
|
{
|
||||||
while (Count > MaxSize)
|
removed = default(TContents);
|
||||||
{
|
|
||||||
TContents removed = m_Collection.First.Value;
|
if (Count <= MaxSize)
|
||||||
m_Collection.RemoveFirst();
|
return false;
|
||||||
OnItemTrimmed.Raise(this, new GenericEventArgs<TContents>(removed));
|
|
||||||
}
|
removed = m_Collection.First.Value;
|
||||||
|
m_Collection.RemoveFirst();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user