Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置Session值
 /// </summary>
 /// <param name="sessionId">Session名称</param>
 /// <param name="value">值</param>
 /// <returns>Session是否被更新</returns>
 public unsafe bool New(ref sessionId sessionId, valueType value)
 {
     if (Pool.Enter())
     {
         try
         {
             sessionId.Index = Pool.GetIndexContinue();
             Pool.Pool[sessionId.Index].New(ref sessionId, date.nowTime.Now.AddTicks(timeoutTicks), value);
         }
         finally { Pool.Exit(); }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// TCP服务端注册
        /// </summary>
        /// <returns>TCP服务端标识</returns>
        internal clientId Register()
        {
            clientInfo    clientInfo = new clientInfo();
            indexIdentity identity;

            if (clientPool.Enter())
            {
                try
                {
                    identity.Index    = clientPool.GetIndexContinue();//不能写成一行,可能造成Pool先入栈然后被修改,导致索引溢出
                    identity.Identity = clientPool.Pool[identity.Index].Set(clientInfo);
                }
                finally { clientPool.Exit(); }
                return(new clientId {
                    Tick = logStream.Ticks, Identity = identity
                });
            }
            clientPool.Exit();
            return(default(clientId));
        }