PWMIS.Core/CommUtil/LRUList.cs
(开头部分) 26KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
#define LockFree
//#undef LockFree
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using PWMIS.Common;
namespace PWMIS.Core
{
/// <summary>
/// 最热访问的名-值 对管理对象,节点被访问的次数越多,越容易被访问到的数据结构
/// </summary>
public class HotNameValue<T> :IDictionary<string,T>
{
const int maxCount = 0xffff;
int hotCount = 3;
int _count = 0;//元素的有效数量
int seekIndex = 0;//发现目标的位置,仅供参考
object sync_obj = new object();
//
DataItem[] dataArr = new DataItem[maxCount];
int[] hotData;
List<DataItem> extList = new List<DataItem>();
MakeWordKey wk = new MakeWordKey();
//SpinLock sl = new SpinLock();
Queue<int> freeQueue = new Queue<int>();//空闲位置队列
/// <summary>
/// 默认构造函数
/// </summary>
public HotNameValue()
{
Init();
}
/// <summary>
/// 初始化热点数据大小,不能大于64,建议在10以内,默认是3
/// </summary>
/// <param name="hot"></param>
public HotNameValue(int hot)
{
if(hot<64 && hot>0)
hotCount = hot;
Init();
}
private void Init()
{
this.Capacity = maxCount;
extList.Add(new DataItem());
hotData = new int[hotCount];
for (int i = 0; i < hotData.Length; i++)
hotData[i] = -1;
}
/// <summary>
后面还有 765 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
