[ObjCRuntime] Implement Runtime.UseAutoreleasePoolInThreadPool for .NET. (#12248)

The getter just returns the runtime appcontext value, while the setter throws
a PlatformNotSupportedException pointing at our documentation about how to
change the value at build time.
This commit is contained in:
Rolf Bjarne Kvinge 2021-07-28 14:30:35 +02:00 коммит произвёл GitHub
Родитель 68476989f4
Коммит 8c1d05a6e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -281,8 +281,7 @@ namespace ObjCRuntime {
#endif
InitializePlatform (options);
#if !XAMMAC_SYSTEM_MONO && !NET_TODO
// NET_TODO: https://github.com/dotnet/runtime/issues/32543
#if !XAMMAC_SYSTEM_MONO && !NET
UseAutoreleasePoolInThreadPool = true;
#endif
IsARM64CallingConvention = GetIsARM64CallingConvention (); // Can only be done after Runtime.Arch is set (i.e. InitializePlatform has been called).
@ -301,8 +300,19 @@ namespace ObjCRuntime {
#endif
}
#if !XAMMAC_SYSTEM_MONO && !NET_TODO
// NET_TODO: https://github.com/dotnet/runtime/issues/32543
#if !XAMMAC_SYSTEM_MONO
#if NET
[EditorBrowsable (EditorBrowsableState.Never)]
[Obsolete ("Use the 'AutoreleasePoolSupport' MSBuild property instead: https://docs.microsoft.com/en-us/dotnet/core/run-time-config/threading#autoreleasepool-for-managed-threads.")]
public static bool UseAutoreleasePoolInThreadPool {
get {
return AppContext.TryGetSwitch ("System.Threading.Thread.EnableAutoreleasePool", out var enabled) && enabled;
}
set {
throw new PlatformNotSupportedException ("Use the 'AutoreleasePoolSupport' MSBuild property instead: https://docs.microsoft.com/en-us/dotnet/core/run-time-config/threading#autoreleasepool-for-managed-threads");
}
}
#else
static bool has_autoreleasepool_in_thread_pool;
public static bool UseAutoreleasePoolInThreadPool {
get {
@ -319,6 +329,7 @@ namespace ObjCRuntime {
using (var pool = new NSAutoreleasePool ())
return callback ();
}
#endif // NET
#endif
#if MONOMAC