From 4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 2 Jan 2008 09:07:11 +0000 Subject: * Trying to address TextureSender issues * The BlockingQueue exposes Contains so we can make sure we don't add a TextureSender to the queue if there's already one present * introduced some TryGetValue and various code convention stuff --- OpenSim/Framework/BlockingQueue.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/BlockingQueue.cs') diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index ae2a189..3ff3dac 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs @@ -32,27 +32,34 @@ namespace OpenSim.Framework { public class BlockingQueue { - private Queue _queue = new Queue(); - private object _queueSync = new object(); + private readonly Queue m_queue = new Queue(); + private readonly object m_queueSync = new object(); public void Enqueue(T value) { - lock (_queueSync) + lock (m_queueSync) { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); + m_queue.Enqueue(value); + Monitor.Pulse(m_queueSync); } } public T Dequeue() { - lock (_queueSync) + lock (m_queueSync) { - if (_queue.Count < 1) - Monitor.Wait(_queueSync); + if (m_queue.Count < 1) + { + Monitor.Wait(m_queueSync); + } - return _queue.Dequeue(); + return m_queue.Dequeue(); } } + + public bool Contains(T item) + { + return m_queue.Contains(item); + } } } \ No newline at end of file -- cgit v1.1