Esempio n. 1
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         QueueLock.EnterYield();
         Buffer value = head;
         end  = null;
         head = null;
         QueueLock.Exit();
         do
         {
             try
             {
                 while (value != null)
                 {
                     value.OnPacket(ref value, onPacket);
                 }
                 break;
             }
             catch (Exception error)
             {
                 log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
             }
         }while (true);
     }while (!isDisposed);
 }
Esempio n. 2
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         QueueLock.EnterYield();
         ServerCallBase value = head;
         end  = null;
         head = null;
         QueueLock.Exit();
         do
         {
             try
             {
                 while (value != null)
                 {
                     current = null;
                     value.RunTask(ref value);
                 }
                 break;
             }
             catch (Exception error)
             {
                 log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
             }
         }while (true);
     }while (!isDisposed);
 }
Esempio n. 3
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         ClientCommand.CommandBase value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         do
         {
             try
             {
                 do
                 {
                     value.OnReceiveTask(ref value);
                 }while (value != null);
                 break;
             }
             catch (Exception error)
             {
                 AutoCSer.Log.Pub.Log.Add(Log.LogType.Error, error);
             }
         }while (value != null);
     }while (true);
 }
Esempio n. 4
0
 /// <summary>
 /// 锁操作任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         Node value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         do
         {
             try
             {
                 do
                 {
                     value = value.RunTask();
                 }while (value != null);
                 break;
             }
             catch (Exception error)
             {
                 value.Lock.Cache.TcpServer.AddLog(error);
             }
             value = value.LinkNext;
         }while (value != null);
     }while (true);
 }
Esempio n. 5
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         Buffer value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         do
         {
             try
             {
                 while (value != null)
                 {
                     onPacket(value);
                     value = value.LinkNext;
                 }
                 break;
             }
             catch (Exception error)
             {
                 log.Add(Log.LogType.Error, error);
             }
             value = value.LinkNext;
         }while (true);
     }while (!isDisposed);
 }
Esempio n. 6
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         ServerCallBase value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         do
         {
             try
             {
                 while (value != null)
                 {
                     current = null;
                     value.RunTask(ref value);
                 }
                 break;
             }
             catch (Exception error)
             {
                 log.Add(Log.LogType.Error, error);
             }
         }while (true);
     }while (!isDisposed);
 }
Esempio n. 7
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         QueueLock.EnterYield();
         ClientCommand.CommandBase value = head;
         end  = null;
         head = null;
         QueueLock.Exit();
         do
         {
             try
             {
                 do
                 {
                     value.OnReceiveTask(ref value);
                 }while (value != null);
                 break;
             }
             catch (Exception error)
             {
                 AutoCSer.LogHelper.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
             }
         }while (value != null);
     }while (true);
 }
Esempio n. 8
0
 public override Task Begin(object obj, SynchronousOptions opts = null)
 {
     return(Task.Run(() =>
     {
         if (WillBegin(obj, opts))
         {
             OnBegun(obj, opts);
             WaitHandle.Wait();
         }
     }));
 }
Esempio n. 9
0
            public override T GetResult()
            {
                if (!IsCompleted)
                {
                    WaitHandle.Wait();
                }

                if (exception != null)
                {
                    exception.Throw();
                }

                return(result);
            }
Esempio n. 10
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         ClientCommand.CommandBase value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         do
         {
             value = value.OnReceiveTask();
         }while (value != null);
     }while (true);
 }
Esempio n. 11
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected override void run()
 {
     do
     {
         WaitHandle.Wait();
         while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         ServerCallBase value = head;
         end  = null;
         head = null;
         System.Threading.Interlocked.Exchange(ref queueLock, 0);
         while (value != null)
         {
             value = value.SingleRunTask();
         }
     }while (!isDisposed);
 }
Esempio n. 12
0
 public Task NotifyAll(bool state)
 {
     if (state)
     {
         return(Task.Run(() =>
         {
             m_allNotified?.Invoke(Id, state);
             WaitHandle.Set();
         }));
     }
     else
     {
         return(Task.Run(() =>
         {
             m_allNotified?.Invoke(Id, state);
             WaitHandle.Wait();
         }));
     }
 }
Esempio n. 13
0
 /// <summary>
 /// TCP 服务器端同步调用任务处理
 /// </summary>
 protected internal override void run()
 {
     do
     {
         CurrentTaskTimestamp = threadArray.NoSwitchTimestamp;
         WaitHandle.Wait();
         ServerCallBase value = Interlocked.Exchange(ref Head, null);
         do
         {
             try
             {
                 do
                 {
                     value.RunTask(ref value, ref CurrentTaskTimestamp);
                 }while (value != null);
                 break;
             }
             catch (Exception error)
             {
                 AutoCSer.LogHelper.Exception(error);
             }
         }while (value != null);
     }while (true);
 }
Esempio n. 14
0
 public void Wait()
 {
     WaitHandle.Wait(TimeSpan.FromSeconds(10));
     WaitHandle.Reset();
 }