Exemple #1
0
        public PlayerSaver AddPlayer(CSCommon.Data.PlayerDataEx roleId)
        {
            PlayerSaver       saver    = null;
            PlayerSaverThread thread   = null;
            Int32             mincount = Int32.MaxValue;

            foreach (var i in mSaveThreads)
            {
                int count = i.GetPlayerCount();
                if (count < mincount)
                {
                    mincount = count;
                    thread   = i;
                }
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    return(saver);
                }
            }

            if (thread == null)
            {
                Log.Log.Common.Print("AddPlayer thread is null");
            }

            saver = thread.AddPlayer(roleId);
            return(saver);
        }
Exemple #2
0
        public void PushExecuter(CSCommon.Data.PlayerDataEx roleId, ServerFrame.DB.AsyncExecuter exec)
        {
            PlayerSaver       saver    = null;
            PlayerSaverThread thread   = null;
            Int32             mincount = Int32.MaxValue;

            foreach (var i in mSaveThreads)
            {
                int count = i.GetPlayerCount();
                if (count < mincount)
                {
                    mincount = count;
                    thread   = i;
                }
                saver = i.FindPlayerSaver(roleId);
                if (saver != null)
                {
                    break;
                }
            }
            if (saver == null)
            {
                saver = thread.AddPlayer(roleId);
            }
            ServerFrame.DB.DBOperator sqlAtom = new ServerFrame.DB.DBOperator();
            sqlAtom.Executer = exec;
            saver.Push(sqlAtom);
            saver.mWaitRemove = false;//只要有数据重新要存储,说明他又登陆进来了,不需要remove了
        }
Exemple #3
0
 public void StartThreadPool(int num)
 {
     for (int i = 0; i < num; i++)
     {
         PlayerSaverThread thread = new PlayerSaverThread();
         thread.StartThread(i);
         mSaveThreads.Add(thread);
     }
 }