diff options
Diffstat (limited to 'OpenSim/Framework/BlockingQueue.cs')
-rw-r--r-- | OpenSim/Framework/BlockingQueue.cs | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index 3658161..aef1192 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 | } |
@@ -89,8 +89,17 @@ namespace OpenSim.Framework | |||
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | /// <summary> | ||
93 | /// Indicate whether this queue contains the given item. | ||
94 | /// </summary> | ||
95 | /// <remarks> | ||
96 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
97 | /// </remarks> | ||
92 | public bool Contains(T item) | 98 | public bool Contains(T item) |
93 | { | 99 | { |
100 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
101 | return false; | ||
102 | |||
94 | lock (m_queueSync) | 103 | lock (m_queueSync) |
95 | { | 104 | { |
96 | if (m_pqueue.Contains(item)) | 105 | if (m_pqueue.Contains(item)) |
@@ -99,16 +108,28 @@ namespace OpenSim.Framework | |||
99 | } | 108 | } |
100 | } | 109 | } |
101 | 110 | ||
111 | /// <summary> | ||
112 | /// Return a count of the number of requests on this queue. | ||
113 | /// </summary> | ||
114 | /// <remarks> | ||
115 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
116 | /// </remarks> | ||
102 | public int Count() | 117 | public int Count() |
103 | { | 118 | { |
104 | lock (m_queueSync) | 119 | return m_queue.Count + m_pqueue.Count; |
105 | { | ||
106 | return m_queue.Count+m_pqueue.Count; | ||
107 | } | ||
108 | } | 120 | } |
109 | 121 | ||
122 | /// <summary> | ||
123 | /// Return the array of items on this queue. | ||
124 | /// </summary> | ||
125 | /// <remarks> | ||
126 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
127 | /// </remarks> | ||
110 | public T[] GetQueueArray() | 128 | public T[] GetQueueArray() |
111 | { | 129 | { |
130 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
131 | return new T[0]; | ||
132 | |||
112 | lock (m_queueSync) | 133 | lock (m_queueSync) |
113 | { | 134 | { |
114 | return m_queue.ToArray(); | 135 | return m_queue.ToArray(); |