Return-Path: Delivered-To: apmail-incubator-lucene-net-commits-archive@minotaur.apache.org Received: (qmail 6877 invoked from network); 14 Nov 2009 15:53:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Nov 2009 15:53:17 -0000 Received: (qmail 14370 invoked by uid 500); 14 Nov 2009 15:53:17 -0000 Delivered-To: apmail-incubator-lucene-net-commits-archive@incubator.apache.org Received: (qmail 14315 invoked by uid 500); 14 Nov 2009 15:53:17 -0000 Mailing-List: contact lucene-net-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@incubator.apache.org Delivered-To: mailing list lucene-net-commits@incubator.apache.org Received: (qmail 14306 invoked by uid 99); 14 Nov 2009 15:53:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Nov 2009 15:53:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Nov 2009 15:53:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 935922388873; Sat, 14 Nov 2009 15:52:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r836197 - /incubator/lucene.net/trunk/C#/src/Test/Util/TestStringIntern.cs Date: Sat, 14 Nov 2009 15:52:44 -0000 To: lucene-net-commits@incubator.apache.org From: aroush@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091114155244.935922388873@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aroush Date: Sat Nov 14 15:52:44 2009 New Revision: 836197 URL: http://svn.apache.org/viewvc?rev=836197&view=rev Log: Fixed NUnit test-cases for: TestStringIntern Modified: incubator/lucene.net/trunk/C#/src/Test/Util/TestStringIntern.cs Modified: incubator/lucene.net/trunk/C#/src/Test/Util/TestStringIntern.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Util/TestStringIntern.cs?rev=836197&r1=836196&r2=836197&view=diff ============================================================================== --- incubator/lucene.net/trunk/C#/src/Test/Util/TestStringIntern.cs (original) +++ incubator/lucene.net/trunk/C#/src/Test/Util/TestStringIntern.cs Sat Nov 14 15:52:44 2009 @@ -16,6 +16,7 @@ */ using System; +using System.Threading; using NUnit.Framework; @@ -29,18 +30,15 @@ { InitBlock(); } - private class AnonymousClassThread:SupportClass.ThreadClass + private class TestRun { - public AnonymousClassThread(System.Int32 seed, int iter, bool newStrings, TestStringIntern enclosingInstance) - { - InitBlock(seed, iter, newStrings, enclosingInstance); - } - private void InitBlock(System.Int32 seed, int iter, bool newStrings, TestStringIntern enclosingInstance) + public TestRun(Int32 seed, int iter, bool newStrings, TestStringIntern enclosingInstance) { this.seed = seed; this.iter = iter; this.newStrings = newStrings; this.enclosingInstance = enclosingInstance; + this.Reset = new ManualResetEvent(false); } private System.Int32 seed; private int iter; @@ -54,7 +52,10 @@ } } - override public void Run() + + public ManualResetEvent Reset; + + public void Run(System.Object state) { System.Random rand = new Random(seed); System.String[] myInterned = new System.String[Enclosing_Instance.testStrings.Length]; @@ -69,19 +70,20 @@ System.String otherInterned = Enclosing_Instance.internedStrings[idx]; // test against other threads - if (otherInterned != null && (System.Object) otherInterned != (System.Object) interned) + if (otherInterned != null && otherInterned != interned) { Assert.Fail(); // TestCase.fail(); } Enclosing_Instance.internedStrings[idx] = interned; // test against local copy - if (prevInterned != null && (System.Object) prevInterned != (System.Object) interned) + if (prevInterned != null && prevInterned != interned) { Assert.Fail(); // TestCase.fail(); } myInterned[idx] = interned; } + this.Reset.Set(); } } private void InitBlock() @@ -125,19 +127,17 @@ // try native intern // StringHelper.interner = new StringInterner(); - SupportClass.ThreadClass[] threads = new SupportClass.ThreadClass[nThreads]; + TestRun[] threads = new TestRun[nThreads]; + ManualResetEvent[] resets = new ManualResetEvent[nThreads]; for (int i = 0; i < nThreads; i++) { int seed = i; - threads[i] = new AnonymousClassThread(seed, iter, newStrings, this); - - threads[i].Start(); - } - - for (int i = 0; i < nThreads; i++) - { - threads[i].Join(); + threads[i] = new TestRun(seed, iter, newStrings, this); + resets[i] = threads[i].Reset; + ThreadPool.QueueUserWorkItem(new WaitCallback(threads[i].Run)); } + + WaitHandle.WaitAll(resets); } } } \ No newline at end of file