diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 6c72edc..d49f1f7 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -1903,112 +1903,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1903 | } | 1903 | } |
1904 | } | 1904 | } |
1905 | } | 1905 | } |
1906 | |||
1907 | internal class DoubleQueue<T> where T:class | ||
1908 | { | ||
1909 | private Queue<T> m_lowQueue = new Queue<T>(); | ||
1910 | private Queue<T> m_highQueue = new Queue<T>(); | ||
1911 | |||
1912 | private object m_syncRoot = new object(); | ||
1913 | private Semaphore m_s = new Semaphore(0, 1); | ||
1914 | |||
1915 | public DoubleQueue() | ||
1916 | { | ||
1917 | } | ||
1918 | |||
1919 | public virtual int Count | ||
1920 | { | ||
1921 | get { return m_highQueue.Count + m_lowQueue.Count; } | ||
1922 | } | ||
1923 | |||
1924 | public virtual void Enqueue(T data) | ||
1925 | { | ||
1926 | Enqueue(m_lowQueue, data); | ||
1927 | } | ||
1928 | |||
1929 | public virtual void EnqueueLow(T data) | ||
1930 | { | ||
1931 | Enqueue(m_lowQueue, data); | ||
1932 | } | ||
1933 | |||
1934 | public virtual void EnqueueHigh(T data) | ||
1935 | { | ||
1936 | Enqueue(m_highQueue, data); | ||
1937 | } | ||
1938 | |||
1939 | private void Enqueue(Queue<T> q, T data) | ||
1940 | { | ||
1941 | lock (m_syncRoot) | ||
1942 | { | ||
1943 | m_lowQueue.Enqueue(data); | ||
1944 | m_s.WaitOne(0); | ||
1945 | m_s.Release(); | ||
1946 | } | ||
1947 | } | ||
1948 | |||
1949 | public virtual T Dequeue() | ||
1950 | { | ||
1951 | return Dequeue(Timeout.Infinite); | ||
1952 | } | ||
1953 | |||
1954 | public virtual T Dequeue(int tmo) | ||
1955 | { | ||
1956 | return Dequeue(TimeSpan.FromMilliseconds(tmo)); | ||
1957 | } | ||
1958 | |||
1959 | public virtual T Dequeue(TimeSpan wait) | ||
1960 | { | ||
1961 | T res = null; | ||
1962 | |||
1963 | if (!Dequeue(wait, ref res)) | ||
1964 | return null; | ||
1965 | |||
1966 | return res; | ||
1967 | } | ||
1968 | |||
1969 | public bool Dequeue(int timeout, ref T res) | ||
1970 | { | ||
1971 | return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res); | ||
1972 | } | ||
1973 | |||
1974 | public bool Dequeue(TimeSpan wait, ref T res) | ||
1975 | { | ||
1976 | if (!m_s.WaitOne(wait)) | ||
1977 | return false; | ||
1978 | |||
1979 | lock (m_syncRoot) | ||
1980 | { | ||
1981 | if (m_highQueue.Count > 0) | ||
1982 | res = m_highQueue.Dequeue(); | ||
1983 | else | ||
1984 | res = m_lowQueue.Dequeue(); | ||
1985 | |||
1986 | if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) | ||
1987 | return true; | ||
1988 | |||
1989 | try | ||
1990 | { | ||
1991 | m_s.Release(); | ||
1992 | } | ||
1993 | catch | ||
1994 | { | ||
1995 | } | ||
1996 | |||
1997 | return true; | ||
1998 | } | ||
1999 | } | ||
2000 | |||
2001 | public virtual void Clear() | ||
2002 | { | ||
2003 | |||
2004 | lock (m_syncRoot) | ||
2005 | { | ||
2006 | // Make sure sem count is 0 | ||
2007 | m_s.WaitOne(0); | ||
2008 | |||
2009 | m_lowQueue.Clear(); | ||
2010 | m_highQueue.Clear(); | ||
2011 | } | ||
2012 | } | ||
2013 | } | ||
2014 | } | 1906 | } |