diff options
Diffstat (limited to 'OpenSim/Framework/BlockingQueue.cs')
-rw-r--r-- | OpenSim/Framework/BlockingQueue.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index 345b361..5b7e911 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs | |||
@@ -32,9 +32,19 @@ namespace OpenSim.Framework | |||
32 | { | 32 | { |
33 | public class BlockingQueue<T> | 33 | public class BlockingQueue<T> |
34 | { | 34 | { |
35 | private readonly Queue<T> m_pqueue = new Queue<T>(); | ||
35 | private readonly Queue<T> m_queue = new Queue<T>(); | 36 | private readonly Queue<T> m_queue = new Queue<T>(); |
36 | private readonly object m_queueSync = new object(); | 37 | private readonly object m_queueSync = new object(); |
37 | 38 | ||
39 | public void PriorityEnqueue(T value) | ||
40 | { | ||
41 | lock (m_queueSync) | ||
42 | { | ||
43 | m_pqueue.Enqueue(value); | ||
44 | Monitor.Pulse(m_queueSync); | ||
45 | } | ||
46 | } | ||
47 | |||
38 | public void Enqueue(T value) | 48 | public void Enqueue(T value) |
39 | { | 49 | { |
40 | lock (m_queueSync) | 50 | lock (m_queueSync) |
@@ -48,11 +58,13 @@ namespace OpenSim.Framework | |||
48 | { | 58 | { |
49 | lock (m_queueSync) | 59 | lock (m_queueSync) |
50 | { | 60 | { |
51 | if (m_queue.Count < 1) | 61 | if (m_queue.Count < 1 && m_pqueue.Count < 1) |
52 | { | 62 | { |
53 | Monitor.Wait(m_queueSync); | 63 | Monitor.Wait(m_queueSync); |
54 | } | 64 | } |
55 | 65 | ||
66 | if(m_pqueue.Count > 0) | ||
67 | return m_pqueue.Dequeue(); | ||
56 | return m_queue.Dequeue(); | 68 | return m_queue.Dequeue(); |
57 | } | 69 | } |
58 | } | 70 | } |
@@ -61,6 +73,8 @@ namespace OpenSim.Framework | |||
61 | { | 73 | { |
62 | lock (m_queueSync) | 74 | lock (m_queueSync) |
63 | { | 75 | { |
76 | if(m_pqueue.Contains(item)) | ||
77 | return true; | ||
64 | return m_queue.Contains(item); | 78 | return m_queue.Contains(item); |
65 | } | 79 | } |
66 | } | 80 | } |
@@ -69,7 +83,7 @@ namespace OpenSim.Framework | |||
69 | { | 83 | { |
70 | lock (m_queueSync) | 84 | lock (m_queueSync) |
71 | { | 85 | { |
72 | return m_queue.Count; | 86 | return m_queue.Count+m_pqueue.Count; |
73 | } | 87 | } |
74 | } | 88 | } |
75 | 89 | ||
@@ -81,4 +95,4 @@ namespace OpenSim.Framework | |||
81 | } | 95 | } |
82 | } | 96 | } |
83 | } | 97 | } |
84 | } \ No newline at end of file | 98 | } |