fastCSharp/memoryDatabase/cache/identityTree.cs
(开头部分) 15KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Threading;
using fastCSharp.setup.cSharp;
namespace fastCSharp.memoryDatabase.cache
{
/// <summary>
/// 自增树缓存
/// </summary>
/// <typeparam name="valueType">数据类型</typeparam>
/// <typeparam name="memberType">数据成员类型</typeparam>
public abstract unsafe class identityTreeBase<valueType, memberType> : identity<valueType, memberType>, ILoadIdentityCache<valueType, memberType, int>
where valueType : class, fastCSharp.data.IPrimaryKey<int>
where memberType : IMemberMap<memberType>
{
/// <summary>
/// 取消自增值
/// </summary>
/// <param name="identity">自增值</param>
public void CancelIdentity(int identity)
{
while (identity > insertIdentity)
{
Thread.Sleep(0);
if (identity > insertIdentity) Thread.Sleep(1);
}
if (identity == insertIdentity) Interlocked.CompareExchange(ref insertIdentity, identity + 1, identity);
}
/// <summary>
/// 删除节点计数
/// </summary>
private int* counts;
/// <summary>
/// 计数节点数量
/// </summary>
private int countSize;
/// <summary>
/// 当前对象索引
/// </summary>
private int currentIndex;
/// <summary>
/// 最大子增值
/// </summary>
private int maxIdentity;
/// <summary>
/// 下一个添加数据对象索引
/// </summary>
private int insertIdentity;
/// <summary>
/// 获取数据对象索引
/// </summary>
/// <param name="identity">自增值</param>
/// <returns>数据对象索引,失败返回null</returns>
private int indexOf(int identity)
{
if (currentIndex != 0)
{
int start = 0, length = currentIndex;
while (start < length)
{
后面还有 360 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
