示例#1
0
 /// <summary>
 /// 打开数据库
 /// </summary>
 /// <param name="fileName">数据文件名</param>
 /// <returns>数据库物理层初始化信息</returns>
 internal physicalServer.physicalIdentity Open(string fileName)
 {
     physicalServer.physicalIdentity physicalInfo = new physicalServer.physicalIdentity {
         Identity = new physicalServer.timeIdentity {
             TimeTick = 0, Index = -1
         }
     };
     if (isDisposed == 0)
     {
         hashString key = fileName;
         if (physicalPool.Enter())
         {
             if (fileNameIndexs.ContainsKey(key))
             {
                 physicalPool.Exit();
             }
             else
             {
                 try
                 {
                     fileNameIndexs.Add(key, physicalInfo.Identity.Index = physicalPool.GetIndexContinue());
                 }
                 finally { physicalPool.Exit(); }
             }
             if (physicalInfo.Identity.Index != -1)
             {
                 try
                 {
                     physical physical = new physical(fileName, false);
                     if (!physical.IsDisposed)
                     {
                         if (physicalPool.Enter())
                         {
                             physicalPool.Pool[physicalInfo.Identity.Index].Set(fileName, physical);
                             physicalPool.Exit();
                         }
                         physicalInfo.Identity.Identity = physicalPool.Pool[physicalInfo.Identity.Index].Identity;
                         physicalInfo.Identity.TimeTick = fastCSharp.pub.StartTime.Ticks;
                         physicalInfo.IsLoader          = physical.IsLoader;
                     }
                 }
                 finally
                 {
                     if (physicalInfo.Identity.TimeTick == 0 && physicalPool.Enter())
                     {
                         fileNameIndexs.Remove(key);
                         physicalPool.Exit();
                     }
                 }
             }
         }
     }
     return(physicalInfo);
 }
示例#2
0
 /// <summary>
 /// 文件读取器
 /// </summary>
 /// <param name="physical">内存数据库物理层</param>
 public fileReader(physical physical)
 {
     this.physical = physical;
     fileStream    = new FileStream(physical.path + physical.fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, fastCSharp.config.appSetting.StreamBufferSize, FileOptions.SequentialScan);
     size          = fileStream.Length;
     waitHandle    = new autoWaitHandle(false);
     clientHandle  = new autoWaitHandle(false);
     if ((size & 3) == 0 && size >= sizeof(int) * 3)
     {
         threadPool.TinyPool.FastStart(this, thread.callType.MemoryDatabasePhysicalFileReader);
     }
     else
     {
         Dispose();
         physical.dataError();
     }
 }
 /// <summary>
 /// 文件读取器
 /// </summary>
 /// <param name="fileName">文件名称</param>
 public fileReader(physical physical)
 {
     this.physical = physical;
     fileStream = new FileStream(physical.path + physical.fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, fastCSharp.config.appSetting.StreamBufferSize, FileOptions.SequentialScan);
     size = fileStream.Length;
     waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
     clientHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
     if ((size & 3) == 0 && size >= sizeof(int) * 3) threadPool.TinyPool.FastStart(read, null, null);
     else
     {
         Dispose();
         physical.dataError();
     }
 }
 /// <summary>
 /// 设置数据库物理层
 /// </summary>
 /// <param name="fileName">数据文件名</param>
 /// <param name="physical">数据库物理层</param>
 public void Set(string fileName, physical physical)
 {
     FileName = fileName;
     Physical = physical;
 }
 /// <summary>
 /// 清除数据库物理层
 /// </summary>
 /// <param name="identity">索引编号</param>
 public void Clear()
 {
     Physical = null;
     FileName.Null();
     ++Identity;
 }
 /// <summary>
 /// 打开数据库
 /// </summary>
 /// <param name="fileName">数据文件名</param>
 /// <returns>数据库物理层初始化信息</returns>
 internal physicalServer.physicalIdentity Open(string fileName)
 {
     physicalServer.physicalIdentity physicalInfo = new physicalServer.physicalIdentity { Identity = new physicalServer.timeIdentity { TimeTick = 0, Index = -1 } };
     if (isDisposed == 0)
     {
         hashString key = fileName;
         interlocked.NoCheckCompareSetSleep0(ref physicalLock);
         try
         {
             if (!fileNameIndexs.ContainsKey(key)) fileNameIndexs.Add(key, physicalInfo.Identity.Index = newIndex());
         }
         finally { physicalLock = 0; }
         if (physicalInfo.Identity.Index != -1)
         {
             try
             {
                 physical physical = new physical(fileName, false);
                 if (!physical.IsDisposed)
                 {
                     interlocked.NoCheckCompareSetSleep0(ref physicalLock);
                     physicals[physicalInfo.Identity.Index].Set(fileName, physical);
                     physicalLock = 0;
                     physicalInfo.Identity.Identity = physicals[physicalInfo.Identity.Index].Identity;
                     physicalInfo.Identity.TimeTick = CoreLibrary.PubPlus.StartTime.Ticks;
                     physicalInfo.IsLoader = physical.IsLoader;
                 }
             }
             finally
             {
                 if (physicalInfo.Identity.TimeTick == 0)
                 {
                     interlocked.NoCheckCompareSetSleep0(ref physicalLock);
                     try
                     {
                         fileNameIndexs.Remove(key);
                     }
                     finally { physicalLock = 0; }
                 }
             }
         }
     }
     return physicalInfo;
 }
示例#7
0
 public void Clear()
 {
     Physical = null;
     FileName.Null();
     ++Identity;
 }
示例#8
0
 public void Set(string fileName, physical physical)
 {
     FileName = fileName;
     Physical = physical;
 }