From 358bc41b034ff2c1e441a5535c9126247229e0c7 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 27 Sep 2008 18:29:17 +0000 Subject: - adding Dequeue with a timeout to the BlockingQueue --- OpenSim/Framework/BlockingQueue.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index 586ccd7..6fbf88f 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs @@ -69,6 +69,23 @@ namespace OpenSim.Framework } } + public T Dequeue(int msTimeout) + { + lock (m_queueSync) + { + if (m_queue.Count < 1 && m_pqueue.Count < 1) + { + Monitor.Wait(m_queueSync, msTimeout); + } + + if (m_pqueue.Count > 0) + return m_pqueue.Dequeue(); + if (m_queue.Count > 0) + return m_queue.Dequeue(); + return default(T); + } + } + public bool Contains(T item) { lock (m_queueSync) -- cgit v1.1