SignalQueue.cs 670 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Concurrent;
  2. namespace TBL.CSharp.Game.Server.Message;
  3. /// <summary>
  4. /// 服务器信号队列
  5. /// </summary>
  6. public class SignalQueue : ConcurrentQueue<Signal>
  7. {
  8. /// <summary>
  9. /// 该队列的持有者
  10. /// </summary>
  11. public readonly Service Owner;
  12. /// <summary>
  13. /// 活跃锁
  14. /// </summary>
  15. internal bool ActiveLock;
  16. public SignalQueue(Service owner)
  17. {
  18. Owner = owner;
  19. ActiveLock = false;
  20. }
  21. ~SignalQueue()
  22. {
  23. Signal signal;
  24. while (TryDequeue(out signal))
  25. {
  26. if (!signal.Data.IsNullPtr)
  27. signal.Data.Free();
  28. }
  29. }
  30. }