aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2013-02-06 04:03:32 +0100
committerMelanie2013-02-06 04:03:32 +0100
commit598f891d703593bde4b96472b5d1b1ce6aaf4c74 (patch)
treeca8d7bebec807f9cdf0cc81a353f3b685b6ccb9c /OpenSim/Framework/Util.cs
parentMake scripts shout a error but not stop when button count is overrun on llDialog (diff)
downloadopensim-SC-598f891d703593bde4b96472b5d1b1ce6aaf4c74.zip
opensim-SC-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.gz
opensim-SC-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.bz2
opensim-SC-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.xz
Move SoubleQueu to Util. Change HTTP inv to prioritize COF. Determine COF for SP
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e76a37b..48f3f8b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2097,4 +2097,112 @@ namespace OpenSim.Framework
2097 } 2097 }
2098 #endregion 2098 #endregion
2099 } 2099 }
2100
2101 public class DoubleQueue<T> where T:class
2102 {
2103 private Queue<T> m_lowQueue = new Queue<T>();
2104 private Queue<T> m_highQueue = new Queue<T>();
2105
2106 private object m_syncRoot = new object();
2107 private Semaphore m_s = new Semaphore(0, 1);
2108
2109 public DoubleQueue()
2110 {
2111 }
2112
2113 public virtual int Count
2114 {
2115 get { return m_highQueue.Count + m_lowQueue.Count; }
2116 }
2117
2118 public virtual void Enqueue(T data)
2119 {
2120 Enqueue(m_lowQueue, data);
2121 }
2122
2123 public virtual void EnqueueLow(T data)
2124 {
2125 Enqueue(m_lowQueue, data);
2126 }
2127
2128 public virtual void EnqueueHigh(T data)
2129 {
2130 Enqueue(m_highQueue, data);
2131 }
2132
2133 private void Enqueue(Queue<T> q, T data)
2134 {
2135 lock (m_syncRoot)
2136 {
2137 m_lowQueue.Enqueue(data);
2138 m_s.WaitOne(0);
2139 m_s.Release();
2140 }
2141 }
2142
2143 public virtual T Dequeue()
2144 {
2145 return Dequeue(Timeout.Infinite);
2146 }
2147
2148 public virtual T Dequeue(int tmo)
2149 {
2150 return Dequeue(TimeSpan.FromMilliseconds(tmo));
2151 }
2152
2153 public virtual T Dequeue(TimeSpan wait)
2154 {
2155 T res = null;
2156
2157 if (!Dequeue(wait, ref res))
2158 return null;
2159
2160 return res;
2161 }
2162
2163 public bool Dequeue(int timeout, ref T res)
2164 {
2165 return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
2166 }
2167
2168 public bool Dequeue(TimeSpan wait, ref T res)
2169 {
2170 if (!m_s.WaitOne(wait))
2171 return false;
2172
2173 lock (m_syncRoot)
2174 {
2175 if (m_highQueue.Count > 0)
2176 res = m_highQueue.Dequeue();
2177 else
2178 res = m_lowQueue.Dequeue();
2179
2180 if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
2181 return true;
2182
2183 try
2184 {
2185 m_s.Release();
2186 }
2187 catch
2188 {
2189 }
2190
2191 return true;
2192 }
2193 }
2194
2195 public virtual void Clear()
2196 {
2197
2198 lock (m_syncRoot)
2199 {
2200 // Make sure sem count is 0
2201 m_s.WaitOne(0);
2202
2203 m_lowQueue.Clear();
2204 m_highQueue.Clear();
2205 }
2206 }
2207 }
2100} 2208}