28 using System.Collections.Generic;
29 using System.Threading;
31 namespace OpenSim.Framework
33 public class BlockingQueue<T>
35 private readonly Queue<T> m_pqueue =
new Queue<T>();
36 private readonly Queue<T> m_queue =
new Queue<T>();
37 private readonly
object m_queueSync =
new object();
43 m_pqueue.Enqueue(value);
44 Monitor.Pulse(m_queueSync);
52 m_queue.Enqueue(value);
53 Monitor.Pulse(m_queueSync);
61 while (m_queue.Count < 1 && m_pqueue.Count < 1)
63 Monitor.Wait(m_queueSync);
66 if (m_pqueue.Count > 0)
67 return m_pqueue.Dequeue();
69 if (m_queue.Count > 0)
70 return m_queue.Dequeue();
79 if (m_queue.Count < 1 && m_pqueue.Count < 1)
81 Monitor.Wait(m_queueSync, msTimeout);
84 if (m_pqueue.Count > 0)
85 return m_pqueue.Dequeue();
86 if (m_queue.Count > 0)
87 return m_queue.Dequeue();
102 if (m_queue.Count < 1 && m_pqueue.Count < 1)
105 if (m_pqueue.Contains(item))
107 return m_queue.Contains(item);
117 return m_queue.Count + m_pqueue.Count;
130 if (m_queue.Count < 1 && m_pqueue.Count < 1)
133 return m_queue.ToArray();
143 Monitor.Pulse(m_queueSync);
int Count()
Return a count of the number of requests on this queue.
void PriorityEnqueue(T value)
bool Contains(T item)
Indicate whether this queue contains the given item.
T[] GetQueueArray()
Return the array of items on this queue.