-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add support for Windows IO completions to the portable thread pool #64834
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
057ceed
Add support for Windows IO completions to the portable thread pool
37a66e0
Translate NtStatus codes to system error codes, fix some other failur…
3233ae0
Fix wasm build
7c0d7d5
Try to fix a time-sensitive test, enable some tests on Mono based on …
759e11a
Enable some more tests on Mono based on #34582
12f40a2
Miscellaneous fixes
0a2dc42
Temporarily enable libraries tests against Mono for this PR
64cca54
Try to fix a time-sensitive test that is occasionally failing
251de07
Note SOS usage of a variable
165842a
Address feedback
81f18f0
Revert "Temporarily enable libraries tests against Mono for this PR"
14893de
Fix build after rebase
a310f12
Add checks for some DOTNET vars from Net.Sockets and implement inlini…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/coreclr/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.Windows.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
| using System.Runtime.Versioning; | ||
|
|
||
| namespace System.Threading | ||
| { | ||
| public static partial class ThreadPool | ||
| { | ||
| [CLSCompliant(false)] | ||
| [SupportedOSPlatform("windows")] | ||
| public static unsafe bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped) | ||
| { | ||
| if (overlapped == null) | ||
| { | ||
| ThrowHelper.ThrowArgumentNullException(ExceptionArgument.overlapped); | ||
| } | ||
|
|
||
| if (UsePortableThreadPoolForIO) | ||
| { | ||
| // OS doesn't signal handle, so do it here | ||
| overlapped->InternalLow = IntPtr.Zero; | ||
|
|
||
| PortableThreadPool.ThreadPoolInstance.QueueNativeOverlapped(overlapped); | ||
| return true; | ||
| } | ||
|
|
||
| return PostQueuedCompletionStatus(overlapped); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| private static extern unsafe bool PostQueuedCompletionStatus(NativeOverlapped* overlapped); | ||
|
|
||
| [Obsolete("ThreadPool.BindHandle(IntPtr) has been deprecated. Use ThreadPool.BindHandle(SafeHandle) instead.")] | ||
| [SupportedOSPlatform("windows")] | ||
| public static bool BindHandle(IntPtr osHandle) | ||
| { | ||
| if (UsePortableThreadPoolForIO) | ||
| { | ||
| PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle); | ||
| return true; | ||
| } | ||
|
|
||
| return BindIOCompletionCallbackNative(osHandle); | ||
| } | ||
|
|
||
| [SupportedOSPlatform("windows")] | ||
| public static bool BindHandle(SafeHandle osHandle!!) | ||
| { | ||
| bool mustReleaseSafeHandle = false; | ||
| try | ||
| { | ||
| osHandle.DangerousAddRef(ref mustReleaseSafeHandle); | ||
|
|
||
| if (UsePortableThreadPoolForIO) | ||
| { | ||
| PortableThreadPool.ThreadPoolInstance.RegisterForIOCompletionNotifications(osHandle.DangerousGetHandle()); | ||
| return true; | ||
| } | ||
|
|
||
| return BindIOCompletionCallbackNative(osHandle.DangerousGetHandle()); | ||
| } | ||
| finally | ||
| { | ||
| if (mustReleaseSafeHandle) | ||
| osHandle.DangerousRelease(); | ||
| } | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| private static extern bool BindIOCompletionCallbackNative(IntPtr fileHandle); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.