This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
[WIP] Update System.Threading.Channels for .NET Core 3.0 #32904
Closed
Closed
Changes from all commits
Commits
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
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
20 changes: 20 additions & 0 deletions
20
src/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netcoreapp.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,20 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace System.Threading.Channels | ||
| { | ||
| internal partial class AsyncOperation<TResult> : IThreadPoolWorkItem | ||
| { | ||
| void IThreadPoolWorkItem.Execute() => SetCompletionAndInvokeContinuation(); | ||
|
|
||
| private void UnsafeQueueSetCompletionAndInvokeContinuation() => | ||
| ThreadPool.UnsafeQueueUserWorkItem(this, preferLocal: false); | ||
|
|
||
| private static void QueueUserWorkItem(Action<object> action, object state) => | ||
| ThreadPool.QueueUserWorkItem(action, state, preferLocal: false); | ||
|
|
||
| private static CancellationTokenRegistration UnsafeRegister(CancellationToken cancellationToken, Action<object> action, object state) => | ||
| cancellationToken.UnsafeRegister(action, state); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.netstandard.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,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Threading.Tasks; | ||
|
|
||
| namespace System.Threading.Channels | ||
| { | ||
| internal partial class AsyncOperation<TResult> | ||
| { | ||
| private void UnsafeQueueSetCompletionAndInvokeContinuation() => | ||
| Task.Factory.StartNew(s => ((AsyncOperation<TResult>)s).SetCompletionAndInvokeContinuation(), this, | ||
| CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); | ||
|
|
||
| private static void QueueUserWorkItem(Action<object> action, object state) => | ||
| Task.Factory.StartNew(action, state, | ||
| CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); | ||
|
|
||
| private static CancellationTokenRegistration UnsafeRegister(CancellationToken cancellationToken, Action<object> action, object state) => | ||
| cancellationToken.Register(action, state); | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| <PropertyGroup> | ||
| <BuildConfigurations> | ||
| netstandard; | ||
| netcoreapp; | ||
| </BuildConfigurations> | ||
| </PropertyGroup> | ||
| </Project> | ||
2 changes: 1 addition & 1 deletion
2
src/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible at all to have _schedulingContext == null and sc != null? and if yes, shouldn't we still need to do sc.Post at that time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the code above that assigns _schedulingContext: it's only set to sc if the sc is one we want to respect.
That said, looking at it again there's an existing very-corner-case bug here, pre-existing this change... it's possible sc could be non-null, ts could be non-null, and we want to use the ts, but we'll end up using the sc instead. I'll fix that separately. We should be setting sc to null when we go to check for a task scheduler.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also it is worth adding some assert here. I mean ensuring the the states of sc with _schedulingContext. just in case in the future anyone update the sc initialization code.
In reply to: 226717506 [](ancestors = 226717506)