Пример #1
0
 private static bool ServerTryRemove(long key, out ServerTimerBase v)
 {
     rw_root.AcquireWriterLock(-1);
     try
     {
         _serverTimerList.TryGetValue(key, out v);
         return(_serverTimerList.Remove(key));
     }
     finally
     {
         rw_root.ReleaseWriterLock();
     }
 }
Пример #2
0
 /// <summary>
 /// 注册定时器,将定时器添加到定时器集合以便宿主提供计时服务
 /// </summary>
 /// <param name="timer"></param>
 internal static void RegistrationTimer(ServerTimerBase timer)
 {
     while (true)
     {
         var skey = GetNewTimerKey();
         if (!ServerTryAdd(skey, timer))
         {
             continue;
         }
         timer._id = skey;
         break;
     }
 }
Пример #3
0
 private static bool ServerTryAdd(long skey, ServerTimerBase timer)
 {
     rw_root.AcquireWriterLock(-1);
     try
     {
         {
             if (_serverTimerList.ContainsKey(skey))
             {
                 return(false);
             }
             _serverTimerList.Add(skey, timer);
             return(true);
         }
     }
     finally
     {
         rw_root.ReleaseWriterLock();
     }
 }