This commit is contained in:
CortexCore
2023-10-24 23:38:22 +08:00
parent 2c4710bc5d
commit bd40165ade
152 changed files with 3681 additions and 1531 deletions

View File

@@ -9,6 +9,7 @@ namespace BITKit
/// <typeparam name="T"></typeparam>
public interface IDoubleBuffer<T>
{
bool CanRelease { get; }
T Current { get; }
void Release(T newValue);
event Action<T> OnRelease;
@@ -20,6 +21,8 @@ namespace BITKit
/// <typeparam name="T"></typeparam>
public class DoubleBuffer<T> : IDoubleBuffer<T>
{
public bool CanRelease => _release.Allow;
public T Current
{
get;
@@ -34,6 +37,11 @@ namespace BITKit
_release.SetValueThenAllow(newValue);
}
public void Clear()
{
_release.Clear();
}
public event Action<T> OnRelease;
private readonly Optional<T> _release=new();