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

Enable option to use the Windows ThreadPool #85373

Merged
merged 172 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
2d5b4c6
Split RegisteredWaitHandle.Portable.cs
eduardo-vp Mar 8, 2023
5860353
Split ThreadPoolBoundHandle.cs
eduardo-vp Mar 8, 2023
c0283b6
Create WindowsThreadPool.cs and update ThreadPool files
eduardo-vp Mar 8, 2023
33083ee
Move Win32ThreadPoolBoundHandle.cs implementation to ThreadPoolBoundH…
eduardo-vp Mar 13, 2023
c7925c9
Move Win32ThreadPoolNativeOverlapped.cs implementation to ThreadPoolN…
eduardo-vp Mar 14, 2023
0d188a1
Move Win32ThreadPoolPreAllocatedOverlapped.cs implementation to Threa…
eduardo-vp Mar 14, 2023
2007a13
Fix some dependencies
eduardo-vp Mar 14, 2023
a3d1aea
Fix some dependencies
eduardo-vp Mar 16, 2023
50d8155
Fix some build errors
eduardo-vp Mar 23, 2023
911f415
Split Thread.NativeAot.cs and create Thread.CoreCLR.Windows.cs
eduardo-vp Mar 23, 2023
e0fb07c
More errors fixed
eduardo-vp Mar 23, 2023
b5f2859
Fix next set of errors
eduardo-vp Mar 24, 2023
c6a9d1c
Fix more build errors
eduardo-vp Mar 25, 2023
b7ddda0
Restore Thread files
eduardo-vp Apr 5, 2023
13894d0
Adding some comments
eduardo-vp Apr 5, 2023
7367244
Restore WaitHandle
eduardo-vp Apr 5, 2023
aa0c74e
Fix dependencies
eduardo-vp Apr 6, 2023
af6cfd6
Add some pragmas
eduardo-vp Apr 6, 2023
d2de264
Before adding SafeThreadPoolIOHandle
eduardo-vp Apr 7, 2023
9da7ec3
Add SafeThreadPoolIOHandle and Interop.ThreadPoolIO.cs
eduardo-vp Apr 14, 2023
6c420fa
Most errors fixed
eduardo-vp Apr 14, 2023
157508d
Fix CoreCLR errors
eduardo-vp Apr 15, 2023
1f54bd2
Fix some NativeAOT errors
eduardo-vp Apr 15, 2023
6a972ed
Fix building errors
eduardo-vp Apr 17, 2023
4727ea3
Fix RegisteredWaitHandle
eduardo-vp Apr 24, 2023
cb38e38
Remove AotCommonPath + Sort Aot dependencies
eduardo-vp Apr 25, 2023
25319b4
OnFinalRelease only if WindowsThreadPool is enabled
eduardo-vp Apr 25, 2023
cf84c03
Moving RegisteredWaitCallback to a single place
eduardo-vp Apr 26, 2023
bbf441b
Move RestartWait to a single place
eduardo-vp Apr 26, 2023
54ae7e6
Nit in ThreadPoolBoundHandle
eduardo-vp Apr 26, 2023
83e1554
Add PerformCallback to RegisteredWaitHandle.Portable.cs
eduardo-vp Apr 26, 2023
9db8828
Merge with main
eduardo-vp Apr 26, 2023
7fc89a6
Move switch files to libraries and rename them
eduardo-vp Apr 27, 2023
5e4e6cd
Move nativeaot files under libraries
eduardo-vp Apr 28, 2023
4cc04db
NativeAotSourcesRoot
eduardo-vp Apr 28, 2023
1d654d6
Move Portable ThreadPool implementation to ThreadPool.CoreCLR.Core.cs…
eduardo-vp Apr 28, 2023
5c8d29c
Allow Mono to switch between portable and windows thread pool
eduardo-vp Apr 28, 2023
e4612e5
Delete UnmanagedThreadPoolWorkItem + place calls to PortableThreadPoo…
eduardo-vp Apr 28, 2023
64b279b
Move imports of Interop.ThreadPool.cs and Interop.ThreadPoolIO.cs to …
eduardo-vp Apr 28, 2023
4a97daf
Make *Core methods private
eduardo-vp Apr 28, 2023
272455c
Restore compability supressions
eduardo-vp Apr 28, 2023
a8278b5
Remove ThreadPool.CoreCLR.cs
eduardo-vp Apr 28, 2023
03dfd3e
Remove PreAllocatedOverlapped.Portable.cs
eduardo-vp Apr 28, 2023
26bd6ac
Move CompleteWaitThreadPoolWorkItem to libraries
eduardo-vp Apr 28, 2023
42f3317
Move most of ThreadPool.CoreCLR.Core to libraries
eduardo-vp May 2, 2023
3645b3a
Use code in libraries instead of Win32ThreadPoolBoundHandle
eduardo-vp May 3, 2023
adcc33b
ThreadPool.CoreCLR.Core.cs -> ThreadPool.CoreCLR.cs | Trimming missin…
eduardo-vp May 3, 2023
0db9013
Add switch to ILLink.Substitutions.Shared.xml
eduardo-vp May 3, 2023
0cb6edd
Camel case used in overlapped files
eduardo-vp May 4, 2023
4296e0a
Revert changes in RuntimeEventSource
eduardo-vp May 4, 2023
89f10b5
Fix NativeAOT build
eduardo-vp May 4, 2023
3c5d3f6
Move Win32ThreadPoolPreAllocatedOverlapped.cs and Win32ThreadPoolRegi…
eduardo-vp May 4, 2023
a6f967b
Revert changes in Thread.cs and ThreadPool.Portable.Unix.cs. Rename t…
eduardo-vp May 4, 2023
a76d74c
Allow NativeAOT to switch between windows and portable threadpoopl
eduardo-vp May 4, 2023
e98773a
Remote ThreadPool.Windows.cs
eduardo-vp May 4, 2023
edc7a2f
Fix clr on unix
eduardo-vp May 5, 2023
4672af9
Fix clr on windows
eduardo-vp May 5, 2023
90edcbe
RegisteredWaitHandle properties using corresponding fields
eduardo-vp May 8, 2023
328786b
Nit in RegisteredWaitHandle.cs
eduardo-vp May 8, 2023
17538af
Make UseWindowsThreadPool a property
eduardo-vp May 9, 2023
a893396
Add partial modifiers
eduardo-vp May 9, 2023
cf13b13
Update UseWindowsThreadPool property + Trimming tests template
eduardo-vp May 9, 2023
f0c0f8d
Nit in System.Runtime.TrimmingTests.proj
eduardo-vp May 9, 2023
0814be8
Fix ReportThreadStatus not found on wasm
eduardo-vp May 10, 2023
a7e6528
Update src/libraries/System.Private.CoreLib/src/System/Threading/Comp…
eduardo-vp May 10, 2023
2a93ef4
Fix browser/mono/wasm
eduardo-vp May 10, 2023
2502f20
Temporarily removing changes in ILLink.Substitutions.Shared.xml
eduardo-vp May 10, 2023
4673d2b
Safe check in BindHandle
eduardo-vp May 11, 2023
0c86ba4
Update ILLink.Substitutions.Shared.xml
eduardo-vp May 11, 2023
c2c0174
Set Trimming for Windows only
eduardo-vp May 11, 2023
f8539d3
Remove switch from ILLink.Substitutions.Shared.xml
eduardo-vp May 11, 2023
a1b785e
Add Trimming tests
eduardo-vp May 12, 2023
f1808b7
Update System.Runtime.TrimmingTests.proj - run tests on Windows only
eduardo-vp May 12, 2023
fba93f3
Setting default value of UseWindowsThreadPool to true. Just for testing
eduardo-vp May 12, 2023
352cb73
Enable ThreadPoolCallbackWrapper in NativeAOT
eduardo-vp May 15, 2023
64b9961
Restore ManagedThreadId.cs
eduardo-vp May 17, 2023
3ea8ef1
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 17, 2023
c182642
Update src/libraries/System.Private.CoreLib/src/System/Threading/Wind…
eduardo-vp May 17, 2023
e29c0d0
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 17, 2023
4fb0a4a
Update src/libraries/System.Private.CoreLib/src/System/Threading/Port…
eduardo-vp May 17, 2023
65428f2
Rename ThreadPool.cs to ThreadPool.Windows.cs
eduardo-vp May 17, 2023
f4ee52f
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 17, 2023
569798b
Restore condition for PortableThreadPool
eduardo-vp May 17, 2023
b0e7172
Make Handle property in RegisteredWaitHandle non-nullable. Set Featur…
eduardo-vp May 17, 2023
76e0bcb
Rename PreAllocatedOverlapped.cs to PreAllocatedOverlapped.Windows.cs
eduardo-vp May 17, 2023
9a33eeb
Adding xml to PreAllocatedOverlapped::UnsafeCreate
eduardo-vp May 18, 2023
bb8c78d
Remove xml from PreAllocatedOverlapped::UnsafeCreatePortableCore
eduardo-vp May 18, 2023
e074410
Sort usings
eduardo-vp May 18, 2023
4d1c2dd
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 18, 2023
86087bc
Renaming: *Core to *WindowsThreadPool
eduardo-vp May 18, 2023
cea582b
Merging ThreadPoolBoundHandle.cs and ThreadPoolBoundHandle.Windows.cs
eduardo-vp May 18, 2023
b97d175
Renaming: RegisteredWaitHandle.cs to RegisteredWaitHandle.Windows.cs
eduardo-vp May 18, 2023
eb2c9fd
Make threadLocalCompletionCountObject in ThreadPoolWorkQueue.cs nullable
eduardo-vp May 18, 2023
fbc8a6e
Merge branch 'main' into feature/enable-windows-threadpool
eduardo-vp May 18, 2023
a40bb4e
Testing: disable trimming + enable windows threadpool by default
eduardo-vp May 19, 2023
988d53f
Add wrapper to WindowsThreadPool::DispatchCallback
eduardo-vp May 19, 2023
fcb97c6
Add xml to ThreadPoolBoundHandle::BindHandle
eduardo-vp May 19, 2023
b9c462f
Merging ThreadPoolBoundHandle.Portable.cs with ThreadPoolBoundHandle.…
eduardo-vp May 19, 2023
f66a503
Renaming: ThreadPoolBoundHandle.Portable.Core.cs to ThreadPoolBoundHa…
eduardo-vp May 19, 2023
a769503
Removing IsWorkerTrackingEnabledInConfig from WindowsThreadPool class
eduardo-vp May 19, 2023
16cdae4
Refactor IsWorkerTrackingEnabledInConfig
eduardo-vp May 19, 2023
09b3f2e
Refactor YieldFromDispatchLoop
eduardo-vp May 19, 2023
45787e4
Fix ThreadPool.Unix.cs
eduardo-vp May 19, 2023
6d85f82
Update System.Private.CoreLib.Shared.projitems
eduardo-vp May 19, 2023
5288082
Renaming RegisteredWaitHandle files
eduardo-vp May 19, 2023
db02dac
Fix System.Private.CoreLib.Shared.projitems
eduardo-vp May 19, 2023
78a9764
Renaming: PreAllocatedOverlapped.Portable.Core.cs to PreAllocatedOver…
eduardo-vp May 19, 2023
8e1fee3
Moving BindHandlePortableCore to ThreadPoolBoundHandle.Portable
eduardo-vp May 20, 2023
b80a136
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 20, 2023
bf6e471
Assertion in ThreadPoolBoundHandle finalizer
eduardo-vp May 20, 2023
e673550
Delete some comments
eduardo-vp May 20, 2023
028005f
Add some comments
eduardo-vp May 20, 2023
e68c5b9
Fix BindHandlePortableCore
eduardo-vp May 23, 2023
288c04d
Unnecesarry checks in ThreadPoolBoundHandle.Unix.cs removed
eduardo-vp May 23, 2023
2b4fdf5
Partial modified removed in ThreadPoolBoundHandle.Browser.Mono.cs
eduardo-vp May 23, 2023
c87c53b
Remove ReportThreadStatusCore
eduardo-vp May 23, 2023
cfb7b8b
Remove ThreadPool.Mono.cs
eduardo-vp May 23, 2023
0c722a6
Partial modified in ThreadPool.Browser.Mono.cs removed
eduardo-vp May 23, 2023
3b73bf2
Partial modifier in PreAllocatedOverlapped.Browser.Mono.cs removed
eduardo-vp May 23, 2023
711546d
ThreadPoolPreAllocatedOverlapped.WindowsThreadPool.cs renamed to PreA…
eduardo-vp May 23, 2023
d393fd5
Place fields and properties from RegisteredWaitHandle.Windows.cs to t…
eduardo-vp May 23, 2023
dd02c79
Fix RegisteredWaitHandle on Unix
eduardo-vp May 23, 2023
afd1057
Renamed ThreadPool.Portable.cs to ThreadPool.NonCoreCLR.cs
eduardo-vp May 23, 2023
24bb2df
Add ReportThreadStatus to ThreadPool.Browser.Mono.cs
eduardo-vp May 23, 2023
3e51deb
Place XML on public methods
eduardo-vp May 23, 2023
7673336
Fix ThreadPoolCallbackWrapper
eduardo-vp May 24, 2023
e6bbd3b
Cache Thread.CurrentThread
eduardo-vp May 24, 2023
8ea3735
Set WorkerTracking to false when Windows thread pool is enabled
eduardo-vp May 24, 2023
0c58c8b
Update comment on RegisteredWaitHandle::PerformCallbackWindowsThreadPool
eduardo-vp May 24, 2023
b38ff77
Remove assertions in ThreadPoolBoundHandle::BindHandle
eduardo-vp May 24, 2023
71ea96f
Enable Windows thread pool timer
eduardo-vp May 24, 2023
cbdbe58
Add Timer.WindowsThreadPool.cs only on Windows
eduardo-vp May 24, 2023
ec6eebc
Fix TimerQueue.Browser.Mono.cs
eduardo-vp May 25, 2023
d9d5802
Fix browser buid
eduardo-vp May 25, 2023
b519b17
Enable FeaturePortableTimer on NativeAot
eduardo-vp May 25, 2023
6da6201
Supress Finalizer on RegisteredWaitHandle
eduardo-vp May 25, 2023
2acc143
Throw argument exception in ThreadPoolBoundHandle.Unix.cs
eduardo-vp May 25, 2023
7a5e7b7
Set UseWindowsThreadPool=true for testing
eduardo-vp May 25, 2023
f8bf852
Revert "Set UseWindowsThreadPool=true for testing"
eduardo-vp May 25, 2023
53521b8
Enable trimming
eduardo-vp May 25, 2023
00fe833
Remove redundant assertions
eduardo-vp May 26, 2023
de39881
Fix IsWorkerTrackingEnabledInConfig in ThreadPool.Windows.cs
eduardo-vp May 26, 2023
883d966
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 26, 2023
d70d86e
Renamed BindHandleCore to BindHandlePortableCore
eduardo-vp May 29, 2023
09e932e
Fix Timer* files
eduardo-vp May 29, 2023
4e56e7b
Move constructor to TimerQueue.Windows.cs
eduardo-vp May 29, 2023
b59b980
Removed GetEnableWorkerTracking()
eduardo-vp May 29, 2023
71c83d0
Added TickCount64 to TimerQueue.Browser.Mono.cs
eduardo-vp May 29, 2023
cfc1fa1
Enable Windows Threadpool tests
eduardo-vp May 31, 2023
51df61e
Updated System.Threading.ThreadPool.sln
eduardo-vp May 31, 2023
8c93a14
Remove MinimumVisualStudioVersion
eduardo-vp May 31, 2023
059f1a1
Set System.Threading.ThreadPool.UseWindowsThreadPool to false in Syst…
eduardo-vp May 31, 2023
553f226
Disable tests that call SetMinThreads/SetMaxThreads for WindowsThread…
eduardo-vp May 31, 2023
156f7e5
Disabling MetricTest() for Windows Threadpool
eduardo-vp May 31, 2023
37c096a
Update src/libraries/System.Private.CoreLib/src/System/Threading/Thre…
eduardo-vp May 31, 2023
6064280
Remove ThreadPool.NonCoreCLR.cs
eduardo-vp May 31, 2023
14b3ff0
Remove conditions for YieldFromDispatchLoop in ThreadPool.Windows.cs
eduardo-vp Jun 1, 2023
01d7da3
Removed EnsureConfigInitializedCore() in ThreadPool.Unix.cs
eduardo-vp Jun 1, 2023
72c84b3
Fix EnsureConfigInitialized()
eduardo-vp Jun 1, 2023
4471f52
Updated EnsureConfigInitialized() to internal
eduardo-vp Jun 1, 2023
e887277
Enabled Windows ThreadPool on Native AOT by default
eduardo-vp Jun 1, 2023
21375a8
Added windows condition to UseWindowsThreadPool in Microsoft.NETCore.…
eduardo-vp Jun 1, 2023
fd3e2f9
Fixed bug
eduardo-vp Jun 1, 2023
23ed1f2
Fix bug in Microsoft.NETCore.Native.targets
eduardo-vp Jun 1, 2023
3646176
Fixed bug in Microsoft.NETCore.Native.targets + Enabled MetricsTest f…
eduardo-vp Jun 2, 2023
0651298
Fixed ThreadCount for WindowsThreadPool on Clr+Mono
eduardo-vp Jun 2, 2023
56be9f1
Fixed InitializeForThreadPoolThread
eduardo-vp Jun 5, 2023
659e1c5
Merged with main
eduardo-vp Jun 6, 2023
2d2a640
Fixed review comments
eduardo-vp Jun 6, 2023
eb70d53
Removed [UnsupportedOSPlatform(browser)] from RegisteredWaitHandle.Un…
eduardo-vp Jun 6, 2023
efa6420
Removed CoreLib's reference in System.Threading.ThreadPool.sln
eduardo-vp Jun 6, 2023
117778c
Merge with main + Fix conflicts
eduardo-vp Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -288,7 +288,6 @@
<Compile Include="$(CommonPath)Interop\Windows\OleAut32\Interop.VariantClear.cs">
<Link>Common\Interop\Windows\OleAut32\Interop.VariantClear.cs</Link>
</Compile>
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.CoreCLR.Windows.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureObjCMarshal)' == 'true'">
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ObjectiveCMarshal.CoreCLR.cs" />
Expand Down
Expand Up @@ -275,17 +275,17 @@ private bool SetApartmentStateUnchecked(ApartmentState state, bool throwOnError)
#else // FEATURE_COMINTEROP_APARTMENT_SUPPORT
private static bool SetApartmentStateUnchecked(ApartmentState state, bool throwOnError)
{
if (state != ApartmentState.Unknown)
{
if (state != ApartmentState.Unknown)
{
if (throwOnError)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
}

return false;
}
}

return true;
return true;
}
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT

Expand Down

This file was deleted.

@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/*=============================================================================
Expand All @@ -18,34 +18,10 @@

namespace System.Threading
{
internal sealed partial class CompleteWaitThreadPoolWorkItem : IThreadPoolWorkItem
{
void IThreadPoolWorkItem.Execute() => CompleteWait();

// Entry point from unmanaged code
private void CompleteWait()
{
PortableThreadPool.CompleteWait(_registeredWaitHandle, _timedOut);
}
}

internal sealed class UnmanagedThreadPoolWorkItem : IThreadPoolWorkItem
{
private readonly IntPtr _callback;
private readonly IntPtr _state;

public UnmanagedThreadPoolWorkItem(IntPtr callback, IntPtr state)
{
_callback = callback;
_state = state;
}

unsafe void IThreadPoolWorkItem.Execute() => ((delegate* unmanaged<IntPtr, int>)_callback)(_state);
}

public static partial class ThreadPool
{
internal static bool EnsureConfigInitialized()
private static bool EnsureConfigInitializedCore()
{
return s_initialized;
}
Expand Down Expand Up @@ -103,113 +79,5 @@ private static unsafe bool InitializeConfig()
private static bool GetEnableWorkerTracking() =>
AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.EnableWorkerTracking", false);

public static bool SetMaxThreads(int workerThreads, int completionPortThreads)
{
return PortableThreadPool.ThreadPoolInstance.SetMaxThreads(workerThreads, completionPortThreads);
}

public static void GetMaxThreads(out int workerThreads, out int completionPortThreads)
{
PortableThreadPool.ThreadPoolInstance.GetMaxThreads(out workerThreads, out completionPortThreads);
}

public static bool SetMinThreads(int workerThreads, int completionPortThreads)
{
return PortableThreadPool.ThreadPoolInstance.SetMinThreads(workerThreads, completionPortThreads);
}

public static void GetMinThreads(out int workerThreads, out int completionPortThreads)
{
PortableThreadPool.ThreadPoolInstance.GetMinThreads(out workerThreads, out completionPortThreads);
}

public static void GetAvailableThreads(out int workerThreads, out int completionPortThreads)
{
PortableThreadPool.ThreadPoolInstance.GetAvailableThreads(out workerThreads, out completionPortThreads);
}

/// <summary>
/// Gets the number of thread pool threads that currently exist.
/// </summary>
/// <remarks>
/// For a thread pool implementation that may have different types of threads, the count includes all types.
/// </remarks>
public static int ThreadCount
{
get
{
return PortableThreadPool.ThreadPoolInstance.ThreadCount;
}
}

/// <summary>
/// Gets the number of work items that have been processed so far.
/// </summary>
/// <remarks>
/// For a thread pool implementation that may have different types of work items, the count includes all types.
/// </remarks>
public static long CompletedWorkItemCount
{
get
{
return PortableThreadPool.ThreadPoolInstance.CompletedWorkItemCount;
}
}

private static RegisteredWaitHandle RegisterWaitForSingleObject(
WaitHandle waitObject,
WaitOrTimerCallback callBack,
object? state,
uint millisecondsTimeOutInterval,
bool executeOnlyOnce,
bool flowExecutionContext)
{
ArgumentNullException.ThrowIfNull(waitObject);
ArgumentNullException.ThrowIfNull(callBack);

RegisteredWaitHandle registeredWaitHandle = new RegisteredWaitHandle(
waitObject,
new _ThreadPoolWaitOrTimerCallback(callBack, state, flowExecutionContext),
(int)millisecondsTimeOutInterval,
!executeOnlyOnce);

PortableThreadPool.ThreadPoolInstance.RegisterWaitHandle(registeredWaitHandle);

return registeredWaitHandle;
}

internal static void RequestWorkerThread()
{
PortableThreadPool.ThreadPoolInstance.RequestWorker();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool NotifyWorkItemComplete(object? threadLocalCompletionCountObject, int currentTimeMs)
{
return
PortableThreadPool.ThreadPoolInstance.NotifyWorkItemComplete(
threadLocalCompletionCountObject,
currentTimeMs);
}

internal static void ReportThreadStatus(bool isWorking)
{
PortableThreadPool.ThreadPoolInstance.ReportThreadStatus(isWorking);
}

internal static void NotifyWorkItemProgress()
{
PortableThreadPool.ThreadPoolInstance.NotifyWorkItemProgress();
}

internal static bool NotifyThreadBlocked() => PortableThreadPool.ThreadPoolInstance.NotifyThreadBlocked();

internal static void NotifyThreadUnblocked()
{
PortableThreadPool.ThreadPoolInstance.NotifyThreadUnblocked();
}

internal static object? GetOrCreateThreadLocalCompletionCountObject() =>
PortableThreadPool.ThreadPoolInstance.GetOrCreateThreadLocalCompletionCountObject();
}
}
Expand Up @@ -236,7 +236,6 @@
<Compile Include="System\Threading\ObjectHeader.cs" />
<Compile Include="System\Threading\SyncTable.cs" />
<Compile Include="System\Threading\Thread.NativeAot.cs" />
<Compile Include="System\Threading\ThreadPool.NativeAot.cs" />
<Compile Include="System\Type.NativeAot.cs" />
<Compile Include="System\Type.Internal.cs" />
<Compile Include="System\TypedReference.cs" />
Expand All @@ -254,7 +253,6 @@
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)'=='true'">
<Compile Include="Microsoft\Win32\SafeHandles\SafeThreadPoolIOHandle.cs" />
<Compile Include="System\Runtime\InteropServices\NativeLibrary.NativeAot.Windows.cs" />
<Compile Include="System\Runtime\InteropServices\PInvokeMarshal.Windows.cs" />
<Compile Include="$(CommonPath)\System\Runtime\InteropServices\Variant.cs">
Expand Down Expand Up @@ -285,9 +283,6 @@
<Compile Include="$(CommonPath)\Interop\Windows\Kernel32\Interop.GetTickCount64.cs">
<Link>Interop\Windows\Kernel32\Interop.GetTickCount64.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Kernel32\Interop.ThreadPool.cs">
<Link>Interop\Windows\Kernel32\Interop.ThreadPool.cs</Link>
</Compile>
<Compile Include="System\Threading\Timer.Windows.cs" Condition="'$(FeaturePortableTimer)' != 'true'" />
<Compile Include="$(CommonPath)\Interop\Windows\Kernel32\Interop.Timer.cs">
<Link>Interop\Windows\Kernel32\Interop.Timer.cs</Link>
Expand All @@ -296,18 +291,12 @@
<Link>Interop\Windows\Kernel32\Interop.DynamicLoad.cs</Link>
</Compile>
<Compile Include="System\Threading\Thread.NativeAot.Windows.cs" />
<Compile Include="$(CommonPath)\Interop\Windows\Kernel32\Interop.ThreadPoolIO.cs">
<Link>Interop\Windows\Kernel32\Interop.ThreadPoolIO.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)'=='true' and '$(FeaturePortableThreadPool)' != 'true'">
<Compile Include="System\Threading\ThreadPool.Windows.cs" />
<Compile Include="System\Threading\ThreadPoolCallbackWrapper.cs" />
<Compile Include="System\Threading\Win32ThreadPoolBoundHandle.cs" />
<Compile Include="System\Threading\Win32ThreadPoolNativeOverlapped.cs" />
<Compile Include="System\Threading\Win32ThreadPoolNativeOverlapped.ExecutionContextCallbackArgs.cs" />
<Compile Include="System\Threading\Win32ThreadPoolNativeOverlapped.OverlappedData.cs" />
<Compile Include="System\Threading\Win32ThreadPoolPreAllocatedOverlapped.cs" />
<Compile Include="System\Threading\Win32ThreadPoolRegisteredWaitHandle.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)'=='true'">
<Compile Include="System\Environment.NativeAot.Unix.cs" />
Expand Down
Expand Up @@ -155,7 +155,7 @@ public ImmutableIdDispenser AllocateId(out int id)
int childSize = ChildSize;
if (id < childSize)
{
left = left.RecycleId(id);
left = left!.RecycleId(id);
eduardo-vp marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Expand All @@ -167,7 +167,7 @@ public ImmutableIdDispenser AllocateId(out int id)
}
else
{
right = right.RecycleId(id - BitsPerNode);
right = right!.RecycleId(id - BitsPerNode);
}
}
return new ImmutableIdDispenser(left, right, _used - 1, _size, bitmap);
Expand All @@ -185,7 +185,7 @@ public ImmutableIdDispenser AllocateId(out int id)
// when a Thread object cannot be created yet. We also store it in the Thread.CurrentThread object,
// because that object may have longer lifetime than the OS thread.
[ThreadStatic]
private static ManagedThreadId t_currentThreadId;
private static ManagedThreadId? t_currentThreadId;
[ThreadStatic]
private static int t_currentManagedThreadId;

Expand Down Expand Up @@ -238,7 +238,7 @@ public static void RecycleId(int id)
var priorIdDispenser = Volatile.Read(ref s_idDispenser);
for (;;)
{
var updatedIdDispenser = s_idDispenser.RecycleId(id);
var updatedIdDispenser = s_idDispenser!.RecycleId(id);
var interlockedResult = Interlocked.CompareExchange(ref s_idDispenser, updatedIdDispenser, priorIdDispenser);
if (object.ReferenceEquals(priorIdDispenser, interlockedResult))
break;
Expand All @@ -265,7 +265,7 @@ public static ManagedThreadId GetCurrentThreadId()
if (t_currentManagedThreadId == IdNone)
MakeForCurrentThread();

return t_currentThreadId;
return t_currentThreadId!;
}

private static int MakeForCurrentThread()
Expand Down

This file was deleted.