Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@ -401,9 +401,14 @@ namespace MonoTests.System.Threading
{
var v = new ReaderWriterLockSlim ();
int local = 10;
int ready_count = 0;
int entered_count = 0;
const int thread_count = 10;
var r = from i in Enumerable.Range (1, 10) select new Thread (() => {
var r = from i in Enumerable.Range (1, thread_count) select new Thread (() => {
Interlocked.Increment (ref ready_count);
v.EnterReadLock ();
Interlocked.Increment (ref entered_count);
Assert.AreEqual (11, local);
});
@ -415,12 +420,16 @@ namespace MonoTests.System.Threading
t.Start ();
}
Thread.Sleep (200);
while (ready_count != thread_count)
Thread.Sleep (10);
/* Extra up to 2s of sleep to ensure all threads got the chance to enter the lock */
for (int i = 0; i < 200 && v.WaitingReadCount != thread_count; ++i)
Thread.Sleep (10);
local = 11;
// FIXME: Don't rely on Thread.Sleep (200)
Assert.AreEqual (0, v.WaitingWriteCount, "in waiting write");
Assert.AreEqual (10, v.WaitingReadCount, "in waiting read");
Assert.AreEqual (thread_count, v.WaitingReadCount, "in waiting read");
Assert.AreEqual (0, v.WaitingUpgradeCount, "in waiting upgrade");
v.ExitWriteLock ();