L4 is now a burden

This commit is contained in:
Youmu Liu
2026-05-21 19:40:00 +08:00
parent 0681237c3b
commit 15f90aed29
3 changed files with 36 additions and 46 deletions
@@ -119,5 +119,37 @@ namespace StgSharp.HighPerformance.Memory
#endregion
}
[StructLayout(LayoutKind.Sequential)]
public unsafe ref struct Handle : IDisposable
{
private CacheLineMetadata* _head;
private nuint _handle;
private Handle(
nuint handle,
CacheLineMetadata* cacheRefCount
)
{
_handle = handle;
_head = cacheRefCount;
}
[Obsolete("You should not create a CacheLineHandle instance outside a L4", true)]
public Handle() { }
public readonly nuint Address => _handle;
public void Dispose()
{
if (_handle == 0) {
return;
}
_handle = 0;
_ = Interlocked.Decrement(ref _head->RefCount);
}
}
}
}