Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/ObjCRuntime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ unsafe static void Initialize (InitializationOptions* options)
#endif
InitializePlatform (options);

#if !XAMMAC_SYSTEM_MONO && !NET_TODO
// NET_TODO: https:/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).
Expand All @@ -301,8 +300,19 @@ unsafe static void Initialize (InitializationOptions* options)
#endif
}

#if !XAMMAC_SYSTEM_MONO && !NET_TODO
// NET_TODO: https:/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 {
Expand All @@ -319,6 +329,7 @@ static bool ThreadPoolDispatcher (Func<bool> callback)
using (var pool = new NSAutoreleasePool ())
return callback ();
}
#endif // NET
#endif

#if MONOMAC
Expand Down