You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@ -29,6 +29,8 @@
|
||||
// Note: the class existed in 1.1 but the only thing we know about it is that
|
||||
// it has a finalizer ;-)
|
||||
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
@ -105,3 +107,4 @@ namespace MonoCasTests.System.Threading {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -26,7 +26,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
@ -55,7 +55,6 @@ namespace MonoTests.System.Threading {
|
||||
public void SetUp ()
|
||||
{
|
||||
success = false;
|
||||
Thread.CurrentThread.SetCompressedStack (null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -135,7 +134,7 @@ namespace MonoTests.System.Threading {
|
||||
{
|
||||
// this is because Thread.CurrentThread.GetCompressedStack () returns null for an empty
|
||||
// compressed stack while CompressedStack.GetCompressedStack () return "something" empty ;-)
|
||||
CompressedStack.Run (Thread.CurrentThread.GetCompressedStack (), new ContextCallback (Callback), true);
|
||||
CompressedStack.Run (null, new ContextCallback (Callback), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,16 +96,19 @@ namespace MonoTests.System.Threading
|
||||
|
||||
Assert.IsNotNull (exception, "#4");
|
||||
Assert.That (exception, Is.TypeOf (typeof (ApplicationException)), "#5");
|
||||
Assert.AreEqual (1, callTime, "#6");
|
||||
Assert.AreEqual (2, callTime, "#6");
|
||||
}
|
||||
|
||||
[Test, ExpectedException (typeof (InvalidOperationException))]
|
||||
[Category ("NotDotNet")] // nunit results in stack overflow
|
||||
public void MultipleReferenceToValueTest ()
|
||||
{
|
||||
threadLocal = new ThreadLocal<int> (() => threadLocal.Value + 1);
|
||||
try {
|
||||
threadLocal = new ThreadLocal<int> (() => threadLocal.Value + 1);
|
||||
var v = threadLocal.Value;
|
||||
|
||||
var value = threadLocal.Value;
|
||||
Assert.Fail ("#1");
|
||||
} catch (InvalidOperationException e) {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -174,6 +177,42 @@ namespace MonoTests.System.Threading
|
||||
Assert.AreEqual (42, threadLocal.Value, "#4");
|
||||
Assert.AreEqual (1, nTimes, "#5");
|
||||
}
|
||||
|
||||
class SetMreOnFinalize
|
||||
{
|
||||
ManualResetEventSlim m_mres;
|
||||
|
||||
public SetMreOnFinalize (ManualResetEventSlim mres)
|
||||
{
|
||||
m_mres = mres;
|
||||
}
|
||||
|
||||
~SetMreOnFinalize()
|
||||
{
|
||||
m_mres.Set();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisposeOnThreadExit ()
|
||||
{
|
||||
var threadLocal = new ThreadLocal<SetMreOnFinalize>();
|
||||
var mres = new ManualResetEventSlim(false);
|
||||
var thread = new Thread (() => { threadLocal.Value = new SetMreOnFinalize (mres); });
|
||||
|
||||
thread.Start ();
|
||||
thread.Join ();
|
||||
|
||||
SpinWait.SpinUntil (() => {
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
GC.Collect();
|
||||
return mres.IsSet;
|
||||
}, 500);
|
||||
|
||||
if (!mres.IsSet)
|
||||
Assert.Fail ();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -61,6 +61,24 @@ namespace MonoTests.System.Threading
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void QueueUserWorkItem ()
|
||||
{
|
||||
int n = 100000;
|
||||
int total = 0, sum = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (i % 2 == 0)
|
||||
ThreadPool.QueueUserWorkItem (_ => { Interlocked.Decrement (ref sum); Interlocked.Increment (ref total); });
|
||||
else
|
||||
ThreadPool.QueueUserWorkItem (_ => { Interlocked.Increment (ref sum); Interlocked.Increment (ref total); });
|
||||
}
|
||||
var start = DateTime.Now;
|
||||
while ((total != n || sum != 0) && (DateTime.Now - start).TotalSeconds < 60)
|
||||
Thread.Sleep (1000);
|
||||
Assert.IsTrue (total == n, "#1");
|
||||
Assert.IsTrue (sum == 0, "#2");
|
||||
}
|
||||
|
||||
#if NET_4_0
|
||||
event WaitCallback e;
|
||||
|
||||
|
Reference in New Issue
Block a user