From 1290e8db99b238744efcbdc0d7130cbce6fe0804 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 20 Dec 2007 17:51:57 +0000 Subject: [PATCH] Rolling back CF compatibility changes to the BlockingQueue, need testers to see if this fixes the Mono problems git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1535 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/BlockingQueue.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libsecondlife/BlockingQueue.cs b/libsecondlife/BlockingQueue.cs index 1a5cb085..8d95d368 100644 --- a/libsecondlife/BlockingQueue.cs +++ b/libsecondlife/BlockingQueue.cs @@ -25,10 +25,10 @@ */ using System; -using System.Collections; using System.Threading; +using libsecondlife; -namespace libsecondlife +namespace System.Collections { /// /// Same as Queue except Dequeue function blocks until there is an object to return. @@ -36,8 +36,7 @@ namespace libsecondlife /// public class BlockingQueue : Queue { - private bool open = true; - private AutoResetEvent syncEvent = new AutoResetEvent(false); + private bool open; /// /// Create new BlockingQueue. @@ -46,6 +45,7 @@ namespace libsecondlife public BlockingQueue(ICollection col) : base(col) { + open = true; } /// @@ -56,6 +56,7 @@ namespace libsecondlife public BlockingQueue(int capacity, float growFactor) : base(capacity, growFactor) { + open = true; } /// @@ -65,6 +66,7 @@ namespace libsecondlife public BlockingQueue(int capacity) : base(capacity) { + open = true; } /// @@ -73,6 +75,7 @@ namespace libsecondlife public BlockingQueue() : base() { + open = true; } /// @@ -103,7 +106,7 @@ namespace libsecondlife { open = false; base.Clear(); - syncEvent.Set(); // resume any waiting threads + Monitor.PulseAll(base.SyncRoot); // resume any waiting threads } } @@ -137,7 +140,7 @@ namespace libsecondlife { while (open && (base.Count == 0)) { - if (!syncEvent.WaitOne(timeout, false)) + if (!Monitor.Wait(base.SyncRoot, timeout)) throw new InvalidOperationException("Timeout"); } if (open) @@ -153,7 +156,7 @@ namespace libsecondlife { while (open && (base.Count == 0)) { - if (!syncEvent.WaitOne(timeout, false)) + if (!Monitor.Wait(base.SyncRoot, timeout)) return false; } if (open) @@ -175,7 +178,7 @@ namespace libsecondlife lock (base.SyncRoot) { base.Enqueue(obj); - syncEvent.Set(); + Monitor.Pulse(base.SyncRoot); } }