From: Matthew Endsley Date: Wed, 3 Feb 2021 09:15:10 +0000 (-0800) Subject: Use consuming enumerator for queue processing X-Git-Tag: 1.0.0~20^2~10 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=3e7080d3b9c61eba244b2c2280f67ab5cf19a789;p=rhonda%2Fimpostor.hazel.git Use consuming enumerator for queue processing This changes avoids us needing to write the proper error-checking code to see if a queue has been completed vs some unrelated failure. --- diff --git a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs index 98f8301..d3b9fa5 100644 --- a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs +++ b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs @@ -222,10 +222,8 @@ namespace Hazel.Udp.FewerThreads } private void ProcessingLoop() { - while (this.isActive) + foreach (ReceiveMessageInfo msg in this.receiveQueue.GetConsumingEnumerable()) { - ReceiveMessageInfo msg = this.receiveQueue.Take(); - try { this.ReadCallback(msg.Message, msg.Sender, msg.ConnectionId); @@ -243,10 +241,8 @@ namespace Hazel.Udp.FewerThreads private void SendLoop() { - while (this.isActive) + foreach (SendMessageInfo msg in this.sendQueue.GetConsumingEnumerable()) { - SendMessageInfo msg = this.sendQueue.Take(); - try { if (this.socket.Poll(Timeout.Infinite, SelectMode.SelectWrite))