mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
40 lines
810 B
C#
40 lines
810 B
C#
using System.Collections.Generic;
|
|
|
|
namespace RGB.NET.Core;
|
|
|
|
public abstract class AbstractReferenceCounting : IReferenceCounting
|
|
{
|
|
#region Properties & Fields
|
|
|
|
private readonly HashSet<object> _referencingObjects = new();
|
|
|
|
/// <inheritdoc />
|
|
public int ActiveReferenceCount
|
|
{
|
|
get
|
|
{
|
|
lock (_referencingObjects)
|
|
return _referencingObjects.Count;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <inheritdoc />
|
|
public void AddReferencingObject(object obj)
|
|
{
|
|
lock (_referencingObjects)
|
|
_referencingObjects.Add(obj);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void RemoveReferencingObject(object obj)
|
|
{
|
|
lock (_referencingObjects)
|
|
_referencingObjects.Remove(obj);
|
|
}
|
|
|
|
#endregion
|
|
} |