/// <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); }
/// <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); }
/// <summary> /// 获取当前数据 /// </summary> /// <param name="key">关键字</param> /// <param name="isLive">设置为活动数据</param> /// <returns></returns> public valueType Get(ref keyType key, bool isLive = false) { if (current == null) { currentKey = key; if (!datas.TryGetValue(key, out current)) { datas.Add(key, current = new LiveCount(create(ref key), isLive)); if (datas.Count > maxDataCount && freeData.Count != 0) { keyType removeKey = freeData.UnsafePopNode().Key; datas.Remove(removeKey); LiveCount removeValue; freeData.Remove(ref removeKey, out removeValue); } if (!isLive) { freeData.Set(ref key, current); } } } else if (isLive) { setLive(); } return(current.Value); }
/// <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) { current = null; value = value.SingleRunTask(); } }while (!isDisposed); }