internal void AppendWait(CacheGetter getter) { if (IsLoaded && currentGetter == null) { currentGetter = getter; getter.Start(); Append(getter); } else { getter.LinkNext = waitGetterLink; waitGetterLink = getter; } }
/// <summary> /// 下一个获取缓存数据 /// </summary> internal void NextGetter() { if (NewFile == null) { if ((currentGetter = waitGetterLink) != null) { waitGetterLink = currentGetter.LinkNext; currentGetter.Start(); Append(currentGetter); } } else { currentGetter = null; NewFile.Start(File); } }
/// <summary> /// 数据操作完以后的持久化处理 /// </summary> /// <param name="buffer">数据缓冲区</param> private void onOperation(Buffer buffer) { if (File != null) { buffer.Reference(); File.BufferLink.Push(buffer); if (NewFile != null) { buffer.Reference(); NewFile.BufferLink.Push(buffer); } } CacheGetter getter = getterLink; if (getter != null) { CacheGetter father = null; do { if (getter.Append(buffer)) { father = getter; getter = getter.LinkNext; } else { if (getter == currentGetter) { NextGetter(); } getter = getter.LinkNext; if (father == null) { getterLink = getter; } else { father.LinkNext = getter; } } }while (getter != null); } buffer.FreeReference(); }
/// <summary> /// 释放资源 /// </summary> internal void DisposeTcpQueue() { CanWrite = false; if (File != null) { File.Close(); File = null; } CacheGetter getter = waitGetterLink; waitGetterLink = null; while (getter != null) { getter = getter.Cancel(); } getter = getterLink; getterLink = currentGetter = null; while (getter != null) { getter = getter.Cancel(); } }
internal void Append(CacheGetter getter) { getter.LinkNext = getterLink; getterLink = getter; }