l4 handle
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="L4.EvictionRing"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -45,14 +45,16 @@ namespace StgSharp.HighPerformance.Memory
|
||||
|
||||
private nint[] _bucket;
|
||||
|
||||
public void AddNode(EvictionRingNode* node)
|
||||
public void AddNode(
|
||||
CacheLineHead* node
|
||||
)
|
||||
{
|
||||
nint address = node->_address;
|
||||
int hash = (int)(address % (nint)_bucket.Length);
|
||||
nint head = _bucket[hash];
|
||||
if (head != 0)
|
||||
{
|
||||
EvictionRingNode* headNode = (EvictionRingNode*)head;
|
||||
CacheLineHead* headNode = (CacheLineHead*)head;
|
||||
headNode->_prev = node;
|
||||
node->_next = headNode;
|
||||
}
|
||||
@@ -62,17 +64,23 @@ namespace StgSharp.HighPerformance.Memory
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private unsafe struct EvictionRingNode
|
||||
private unsafe struct CacheLineHead
|
||||
{
|
||||
|
||||
public EvictionRingNode* _next;
|
||||
public EvictionRingNode* _prev;
|
||||
public int _level;
|
||||
public int _refCount;
|
||||
public nint _address;
|
||||
internal CacheLineHead* _next;
|
||||
internal CacheLineHead* _prev;
|
||||
internal int _level;
|
||||
internal int _refCount;
|
||||
internal nuint _address;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void IncrementRefCount()
|
||||
public void Unuse()
|
||||
{
|
||||
_ = Interlocked.Decrement(ref _refCount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Use()
|
||||
{
|
||||
_ = Interlocked.Increment(ref _refCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user