diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index efaed6220c..f6e76dc8f9 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2296,11 +2296,6 @@ namespace OpenSim.Framework private Queue m_highQueue = new Queue(); private object m_syncRoot = new object(); - private Semaphore m_s = new Semaphore(0, 1); - - public DoubleQueue() - { - } public virtual int Count { @@ -2329,11 +2324,7 @@ namespace OpenSim.Framework private void Enqueue(Queue q, T data) { lock (m_syncRoot) - { q.Enqueue(data); - m_s.WaitOne(0); - m_s.Release(); - } } public virtual T Dequeue() @@ -2363,42 +2354,31 @@ namespace OpenSim.Framework public bool Dequeue(TimeSpan wait, ref T res) { - if (!m_s.WaitOne(wait)) + if (!Monitor.TryEnter(m_syncRoot, wait)) return false; - lock (m_syncRoot) + try { if (m_highQueue.Count > 0) res = m_highQueue.Dequeue(); else if (m_lowQueue.Count > 0) res = m_lowQueue.Dequeue(); - if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) - return true; - - try - { - m_s.Release(); - } - catch - { - } - return true; } + finally + { + Monitor.Exit(m_syncRoot); + } } public virtual void Clear() { - lock (m_syncRoot) { - // Make sure sem count is 0 - m_s.WaitOne(0); - m_lowQueue.Clear(); m_highQueue.Clear(); } } } -} +} \ No newline at end of file