Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -125,5 +125,8 @@ namespace System.Threading
public static void MemoryBarrier () {
Thread.MemoryBarrier ();
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void MemoryBarrierProcessWide ();
}
}

View File

@@ -31,7 +31,7 @@
//
using System.Runtime.CompilerServices;
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
using System.Runtime.Remoting.Contexts;
#endif
using System.Runtime.ConstrainedExecution;
@@ -77,14 +77,14 @@ namespace System.Threading
throw new SynchronizationLockException ("Object is not synchronized");
try {
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
return Monitor_wait (obj, millisecondsTimeout);
} finally {
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
@@ -116,5 +116,9 @@ namespace System.Threading
{
return Monitor_test_owner (obj);
}
#if NETCORE
public static long LockContentionCount => throw new PlatformNotSupportedException ();
#endif
}
}

View File

@@ -83,8 +83,14 @@ namespace System.Threading
lock (this) {
_unregistered = true;
if (_callsInProcess == 0 && _finalEvent != null)
if (_callsInProcess == 0 && _finalEvent != null) {
#if NETCORE
throw new NotImplementedException ();
#else
NativeEventCalls.SetEvent (_finalEvent.SafeWaitHandle);
_finalEvent = null;
#endif
}
}
} catch (ObjectDisposedException) {
// Can happen if we called Unregister before we had time to execute Wait
@@ -105,8 +111,14 @@ namespace System.Threading
lock (this)
{
_callsInProcess--;
if (_unregistered && _callsInProcess == 0 && _finalEvent != null)
if (_unregistered && _callsInProcess == 0 && _finalEvent != null) {
#if NETCORE
EventWaitHandle.Set (_finalEvent.SafeWaitHandle);
#else
NativeEventCalls.SetEvent (_finalEvent.SafeWaitHandle);
#endif
_finalEvent = null;
}
}
}
}

View File

@@ -166,14 +166,17 @@ namespace System.Threading {
private extern static byte[] ByteArrayToCurrentDomain (byte[] arr);
#if !NETCORE
IPrincipal principal;
int principal_version;
#if !DISABLE_REMOTING
public static Context CurrentContext {
get {
return(AppDomain.InternalGetContext ());
}
}
#endif
#if !DISABLE_SECURITY
IPrincipal principal;
int principal_version;
static void DeserializePrincipal (Thread th)
{
@@ -291,6 +294,12 @@ namespace System.Threading {
th.principal = value;
}
}
#else
public static IPrincipal CurrentPrincipal {
get => throw new PlatformNotSupportedException ();
set => throw new PlatformNotSupportedException ();
}
#endif
public static AppDomain GetDomain() {
return AppDomain.CurrentDomain;

View File

@@ -32,6 +32,7 @@ using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace System.Threading
@@ -64,7 +65,7 @@ namespace System.Threading
[ComVisible (true)]
public sealed class Timer
: MarshalByRefObject, IDisposable
: MarshalByRefObject, IDisposable, IAsyncDisposable
{
static Scheduler scheduler => Scheduler.Instance;
#region Timer instance fields
@@ -200,6 +201,12 @@ namespace System.Threading
return true;
}
public ValueTask DisposeAsync ()
{
Dispose ();
return new ValueTask (Task.FromResult<object> (null));
}
// extracted from ../../../../external/referencesource/mscorlib/system/threading/timer.cs
internal void KeepRootedWhileScheduled()
{

View File

@@ -31,7 +31,7 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
using System.Runtime.Remoting.Contexts;
#endif
using System.Runtime.InteropServices;
@@ -61,7 +61,7 @@ namespace System.Threading
try {
waitableSafeHandle.DangerousAddRef (ref release);
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
@@ -94,7 +94,7 @@ namespace System.Threading
if (release)
waitableSafeHandle.DangerousRelease ();
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
@@ -111,7 +111,7 @@ namespace System.Threading
var context = SynchronizationContext.Current;
try {
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
@@ -151,7 +151,7 @@ namespace System.Threading
waitHandles [i].SafeWaitHandle.DangerousRelease ();
}
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif