Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -31,6 +31,7 @@
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.CompilerServices;
namespace System.Threading
{
@ -153,7 +154,7 @@ namespace System.Threading
return true;
}
} else {
nr = dueTime * TimeSpan.TicksPerMillisecond + DateTime.GetTimeMonotonic ();
nr = dueTime * TimeSpan.TicksPerMillisecond + GetTimeMonotonic ();
}
scheduler.Change (this, nr);
@ -169,6 +170,15 @@ namespace System.Threading
return true;
}
// extracted from ../../../../external/referencesource/mscorlib/system/threading/timer.cs
internal void KeepRootedWhileScheduled()
{
}
// TODO: Environment.TickCount should be enough as is everywhere else
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern long GetTimeMonotonic ();
sealed class TimerComparer : IComparer {
public int Compare (object x, object y)
{
@ -323,7 +333,7 @@ namespace System.Threading
var new_time = new List<Timer> (512);
while (true) {
int ms_wait = -1;
long ticks = DateTime.GetTimeMonotonic ();
long ticks = GetTimeMonotonic ();
lock (this) {
changed.Reset ();
//PrintList ();
@ -344,7 +354,7 @@ namespace System.Threading
if (no_more) {
timer.next_run = Int64.MaxValue;
} else {
timer.next_run = DateTime.GetTimeMonotonic () + TimeSpan.TicksPerMillisecond * timer.period_ms;
timer.next_run = GetTimeMonotonic () + TimeSpan.TicksPerMillisecond * timer.period_ms;
new_time.Add (timer);
}
}
@ -371,7 +381,7 @@ namespace System.Threading
//PrintList ();
ms_wait = -1;
if (min_next_run != Int64.MaxValue) {
long diff = (min_next_run - DateTime.GetTimeMonotonic ()) / TimeSpan.TicksPerMillisecond;
long diff = (min_next_run - GetTimeMonotonic ()) / TimeSpan.TicksPerMillisecond;
if (diff > Int32.MaxValue)
ms_wait = Int32.MaxValue - 1;
else {