mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
* 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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user