aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-16 23:00:07 +0100
committerJustin Clark-Casey (justincc)2013-07-16 23:00:07 +0100
commit50b8ab60f2d4d8a2cc7024012fc1333be7635276 (patch)
tree898d5d485db4bc1ebd2a48cead0ae6008628b39b /OpenSim/Framework
parentRevert "MSDN documentation is unclear about whether exiting a lock() block wi... (diff)
downloadopensim-SC_OLD-50b8ab60f2d4d8a2cc7024012fc1333be7635276.zip
opensim-SC_OLD-50b8ab60f2d4d8a2cc7024012fc1333be7635276.tar.gz
opensim-SC_OLD-50b8ab60f2d4d8a2cc7024012fc1333be7635276.tar.bz2
opensim-SC_OLD-50b8ab60f2d4d8a2cc7024012fc1333be7635276.tar.xz
Revert "Revert "MSDN documentation is unclear about whether exiting a lock() block will trigger a Monitor.Wait() to exit, so avoid some locks that don't actually affect the state of the internal queues in the BlockingQueue class.""
This reverts commit 21a09ad3ad42b24bce4fc04c6bcd6f7d9a80af08. After more analysis and discussion, it is apparant that the Count(), Contains() and GetQueueArray() cannot be made thread-safe anyway without external locking And this change appears to have a positive impact on performance. I still believe that Monitor.Exit() will not release any thread for Monitor.Wait(), as per http://msdn.microsoft.com/en-gb/library/vstudio/system.threading.monitor.exit%28v=vs.100%29.aspx so this should in theory make no difference, though mono implementation issues could possibly be coming into play.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/BlockingQueue.cs13
1 files changed, 8 insertions, 5 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index 3658161..cc016b0 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 }
@@ -91,6 +91,9 @@ namespace OpenSim.Framework
91 91
92 public bool Contains(T item) 92 public bool Contains(T item)
93 { 93 {
94 if (m_queue.Count < 1 && m_pqueue.Count < 1)
95 return false;
96
94 lock (m_queueSync) 97 lock (m_queueSync)
95 { 98 {
96 if (m_pqueue.Contains(item)) 99 if (m_pqueue.Contains(item))
@@ -101,14 +104,14 @@ namespace OpenSim.Framework
101 104
102 public int Count() 105 public int Count()
103 { 106 {
104 lock (m_queueSync) 107 return m_queue.Count+m_pqueue.Count;
105 {
106 return m_queue.Count+m_pqueue.Count;
107 }
108 } 108 }
109 109
110 public T[] GetQueueArray() 110 public T[] GetQueueArray()
111 { 111 {
112 if (m_queue.Count < 1 && m_pqueue.Count < 1)
113 return new T[0];
114
112 lock (m_queueSync) 115 lock (m_queueSync)
113 { 116 {
114 return m_queue.ToArray(); 117 return m_queue.ToArray();