* 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
This commit is contained in:
lbsa71
2008-01-02 09:07:11 +00:00
parent e678056e13
commit 4b4ee98070
6 changed files with 91 additions and 78 deletions

View File

@@ -32,27 +32,34 @@ namespace OpenSim.Framework
{
public class BlockingQueue<T>
{
private Queue<T> _queue = new Queue<T>();
private object _queueSync = new object();
private readonly Queue<T> m_queue = new Queue<T>();
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);
}
}
}