diff options
author | gareth | 2007-03-22 10:11:15 +0000 |
---|---|---|
committer | gareth | 2007-03-22 10:11:15 +0000 |
commit | 7daa3955bc3a1918e40962851f9e8d38597a245e (patch) | |
tree | bee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /OpenSim.Framework/BlockingQueue.cs | |
parent | Load XML for neighbourinfo from grid (diff) | |
download | opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.zip opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2 opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz |
brought zircon branch into trunk
Diffstat (limited to 'OpenSim.Framework/BlockingQueue.cs')
-rw-r--r-- | OpenSim.Framework/BlockingQueue.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/OpenSim.Framework/BlockingQueue.cs b/OpenSim.Framework/BlockingQueue.cs new file mode 100644 index 0000000..f840354 --- /dev/null +++ b/OpenSim.Framework/BlockingQueue.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System; | ||
2 | using System.Threading; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | |||
6 | namespace OpenSim.Framework.Utilities | ||
7 | { | ||
8 | public class BlockingQueue<T> | ||
9 | { | ||
10 | private Queue<T> _queue = new Queue<T>(); | ||
11 | private object _queueSync = new object(); | ||
12 | |||
13 | public void Enqueue(T value) | ||
14 | { | ||
15 | lock (_queueSync) | ||
16 | { | ||
17 | _queue.Enqueue(value); | ||
18 | Monitor.Pulse(_queueSync); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | public T Dequeue() | ||
23 | { | ||
24 | lock (_queueSync) | ||
25 | { | ||
26 | if (_queue.Count < 1) | ||
27 | Monitor.Wait(_queueSync); | ||
28 | |||
29 | return _queue.Dequeue(); | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | } | ||