aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/BlockingQueue.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/BlockingQueue.cs')
-rw-r--r--OpenSim/Framework/BlockingQueue.cs36
1 files changed, 29 insertions, 7 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index 3658161..3e90fac 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Framework
58 { 58 {
59 lock (m_queueSync) 59 lock (m_queueSync)
60 { 60 {
61 if (m_queue.Count < 1 && m_pqueue.Count < 1) 61 while (m_queue.Count < 1 && m_pqueue.Count < 1)
62 { 62 {
63 Monitor.Wait(m_queueSync); 63 Monitor.Wait(m_queueSync);
64 } 64 }
@@ -76,9 +76,10 @@ namespace OpenSim.Framework
76 { 76 {
77 lock (m_queueSync) 77 lock (m_queueSync)
78 { 78 {
79 if (m_queue.Count < 1 && m_pqueue.Count < 1) 79 bool success = true;
80 while (m_queue.Count < 1 && m_pqueue.Count < 1 && success)
80 { 81 {
81 Monitor.Wait(m_queueSync, msTimeout); 82 success = Monitor.Wait(m_queueSync, msTimeout);
82 } 83 }
83 84
84 if (m_pqueue.Count > 0) 85 if (m_pqueue.Count > 0)
@@ -89,8 +90,17 @@ namespace OpenSim.Framework
89 } 90 }
90 } 91 }
91 92
93 /// <summary>
94 /// Indicate whether this queue contains the given item.
95 /// </summary>
96 /// <remarks>
97 /// This method is not thread-safe. Do not rely on the result without consistent external locking.
98 /// </remarks>
92 public bool Contains(T item) 99 public bool Contains(T item)
93 { 100 {
101 if (m_queue.Count < 1 && m_pqueue.Count < 1)
102 return false;
103
94 lock (m_queueSync) 104 lock (m_queueSync)
95 { 105 {
96 if (m_pqueue.Contains(item)) 106 if (m_pqueue.Contains(item))
@@ -99,16 +109,28 @@ namespace OpenSim.Framework
99 } 109 }
100 } 110 }
101 111
112 /// <summary>
113 /// Return a count of the number of requests on this queue.
114 /// </summary>
115 /// <remarks>
116 /// This method is not thread-safe. Do not rely on the result without consistent external locking.
117 /// </remarks>
102 public int Count() 118 public int Count()
103 { 119 {
104 lock (m_queueSync) 120 return m_queue.Count + m_pqueue.Count;
105 {
106 return m_queue.Count+m_pqueue.Count;
107 }
108 } 121 }
109 122
123 /// <summary>
124 /// Return the array of items on this queue.
125 /// </summary>
126 /// <remarks>
127 /// This method is not thread-safe. Do not rely on the result without consistent external locking.
128 /// </remarks>
110 public T[] GetQueueArray() 129 public T[] GetQueueArray()
111 { 130 {
131 if (m_queue.Count < 1 && m_pqueue.Count < 1)
132 return new T[0];
133
112 lock (m_queueSync) 134 lock (m_queueSync)
113 { 135 {
114 return m_queue.ToArray(); 136 return m_queue.ToArray();