L4 is now a burden
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user