Utilities: BlockingQueue: Bugfix: TryDequeue would block infinitely if called after Stop was invoked

This commit is contained in:
Tal Aloni 2025-05-01 17:40:15 +03:00
parent 351f23ead9
commit 21313ac030

View file

@ -1,13 +1,11 @@
/* Copyright (C) 2016-2020 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
/* Copyright (C) 2016-2025 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
*
* You can redistribute this program and/or modify it under the terms of
* the GNU Lesser Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Text;
namespace Utilities
{
@ -57,7 +55,11 @@ namespace Utilities
{
while (m_queue.Count == 0)
{
Monitor.Wait(m_queue);
if (!m_stopping)
{
Monitor.Wait(m_queue);
}
if (m_stopping)
{
item = default(T);