You've already forked linux-packaging-mono
Imported Upstream version 4.4.0.40
Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
@@ -288,7 +288,8 @@ namespace System
|
||||
var Istart = 0;
|
||||
while (Istart < str.Length && !char.IsLetterOrDigit(str[Istart])) Istart++;
|
||||
var Iend = str.Length - 1;
|
||||
while (Iend > Istart && !char.IsLetterOrDigit(str[Iend])) Iend--;
|
||||
while (Iend > Istart && !char.IsLetterOrDigit(str[Iend]) && str[Iend] != ')') // zone name can include parentheses like "Central Standard Time (Mexico)"
|
||||
Iend--;
|
||||
|
||||
return str.Substring (Istart, Iend-Istart+1);
|
||||
}
|
||||
|
@@ -395,6 +395,96 @@ namespace MonoTests.System.Threading {
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO_FEATURE_THREAD_SUSPEND_RESUME
|
||||
[Test]
|
||||
public void WaitOneWithTimeoutAndSpuriousWake ()
|
||||
{
|
||||
/* This is to test that WaitEvent.WaitOne is not going to wait largely
|
||||
* more than its timeout. In this test, it shouldn't wait more than
|
||||
* 1500 milliseconds, with its timeout being 1000ms */
|
||||
|
||||
using (ManualResetEvent mre = new ManualResetEvent (false))
|
||||
using (ManualResetEvent ready = new ManualResetEvent (false)) {
|
||||
var thread = new Thread (() => {
|
||||
ready.Set ();
|
||||
mre.WaitOne (1000);
|
||||
});
|
||||
|
||||
thread.Start ();
|
||||
ready.WaitOne ();
|
||||
|
||||
Thread.Sleep (10); // wait a bit so we enter mre.WaitOne
|
||||
|
||||
DateTime end = DateTime.Now.AddMilliseconds (500);
|
||||
while (DateTime.Now < end) {
|
||||
thread.Suspend ();
|
||||
thread.Resume ();
|
||||
}
|
||||
|
||||
Assert.IsTrue (thread.Join (1000), "#1");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WaitAnyWithTimeoutAndSpuriousWake ()
|
||||
{
|
||||
/* This is to test that WaitEvent.WaitAny is not going to wait largely
|
||||
* more than its timeout. In this test, it shouldn't wait more than
|
||||
* 1500 milliseconds, with its timeout being 1000ms */
|
||||
|
||||
using (ManualResetEvent mre1 = new ManualResetEvent (false))
|
||||
using (ManualResetEvent mre2 = new ManualResetEvent (false))
|
||||
using (ManualResetEvent ready = new ManualResetEvent (false)) {
|
||||
var thread = new Thread (() => {
|
||||
ready.Set ();
|
||||
WaitHandle.WaitAny (new [] { mre1, mre2 }, 1000);
|
||||
});
|
||||
|
||||
thread.Start ();
|
||||
ready.WaitOne ();
|
||||
|
||||
Thread.Sleep (10); // wait a bit so we enter WaitHandle.WaitAny ({mre1, mre2})
|
||||
|
||||
DateTime end = DateTime.Now.AddMilliseconds (500);
|
||||
while (DateTime.Now < end) {
|
||||
thread.Suspend ();
|
||||
thread.Resume ();
|
||||
}
|
||||
|
||||
Assert.IsTrue (thread.Join (1000), "#1");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WaitAllWithTimeoutAndSpuriousWake ()
|
||||
{
|
||||
/* This is to test that WaitEvent.WaitAll is not going to wait largely
|
||||
* more than its timeout. In this test, it shouldn't wait more than
|
||||
* 1500 milliseconds, with its timeout being 1000ms */
|
||||
|
||||
using (ManualResetEvent mre1 = new ManualResetEvent (false))
|
||||
using (ManualResetEvent mre2 = new ManualResetEvent (false))
|
||||
using (ManualResetEvent ready = new ManualResetEvent (false)) {
|
||||
var thread = new Thread (() => {
|
||||
ready.Set ();
|
||||
WaitHandle.WaitAll (new [] { mre1, mre2 }, 1000);
|
||||
});
|
||||
|
||||
thread.Start ();
|
||||
ready.WaitOne ();
|
||||
|
||||
Thread.Sleep (10); // wait a bit so we enter WaitHandle.WaitAll ({mre1, mre2})
|
||||
|
||||
DateTime end = DateTime.Now.AddMilliseconds (500);
|
||||
while (DateTime.Now < end) {
|
||||
thread.Suspend ();
|
||||
thread.Resume ();
|
||||
}
|
||||
|
||||
Assert.IsTrue (thread.Join (1000), "#1");
|
||||
}
|
||||
}
|
||||
#endif // MONO_FEATURE_THREAD_SUSPEND_RESUME
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user