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

Add WithCancellation for async enumerables #21939

Merged
merged 1 commit into from Jan 11, 2019

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Jan 10, 2019

Contributes to https://github.com/dotnet/corefx/issues/33909
cc: @jcouv, @kouvel, @tarekgh

Relates to async-streams umbrella: dotnet/roslyn#24037

{
/// <summary>Provides an awaitable async enumerable that enables cancelable iteration and configured awaits.</summary>
[StructLayout(LayoutKind.Auto)]
public readonly struct ConfiguredCancelableAsyncEnumerable<T>

This comment has been minimized.

@jcouv

jcouv Jan 10, 2019
Member

ConfiguredCancelableAsyncEnumerable [](start = 27, length = 35)

nit: I'm unsure which spelling is more common (cancellable vs. cancelable). I would have gone with two L's.

Apparently, US is one L, and UK is two L's ;-)
https://www.collinsdictionary.com/dictionary/english/cancellable

But I'd still lean towards two L's, to match CancellationToken

This comment has been minimized.

@tarekgh

tarekgh Jan 10, 2019
Member

We have it one L in other places like TaskCanceledException, Task.IsCanceled, Task.FromCanceled, TaskCompletionSource.SetCanceled..etc.

Although we are not consistent in the spelling as CancellationToken uses 2 L's but it looks the majority of the usage is using 1 L.

This comment has been minimized.

@stephentoub

stephentoub Jan 10, 2019
Author Member

Right, we have some inconsistency from early usage of "cancel" in .NET Framework 3.x and earlier. As of .NET Framework 4, we settled on cancel, canceled, canceling, canceler, cancelable, etc., all with one L, and then cancellation with two Ls.

@jcouv
jcouv approved these changes Jan 10, 2019
Copy link
Member

@jcouv jcouv left a comment

LGTM
The spelling question probably doesn't matter much as most people will not see this type. They will see WithCancellation and CancellationToken.
I don't know how testing works. I assume you'll have some coverage in another PR/repo?

@tarekgh
Copy link
Member

@tarekgh tarekgh commented Jan 10, 2019

I don't know how testing works. I assume you'll have some coverage in another PR/repo?

@jcouv you already included in the test changes PR dotnet/corefx#34528

@stephentoub
Copy link
Member Author

@stephentoub stephentoub commented Jan 10, 2019

@dotnet-bot test Ubuntu arm Cross Checked Innerloop Build and Test please

@stephentoub stephentoub merged commit b46881a into dotnet:master Jan 11, 2019
31 checks passed
31 checks passed
CentOS7.1 x64 Checked Innerloop Build and Test Build finished.
Details
CentOS7.1 x64 Debug Innerloop Build Build finished.
Details
Linux-musl x64 Debug Build Build finished.
Details
OSX10.12 x64 Checked Innerloop Build and Test Build finished.
Details
Tizen armel Cross Checked Innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Checked Innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Checked crossgen_comparison Build and Test Build finished.
Details
Ubuntu arm Cross Checked no_tiered_compilation_innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Release crossgen_comparison Build and Test Build finished.
Details
Ubuntu x64 Checked CoreFX Tests Build finished.
Details
Ubuntu x64 Checked Innerloop Build and Test Build finished.
Details
Ubuntu x64 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Ubuntu x64 Formatting Build finished.
Details
Ubuntu16.04 arm64 Cross Checked Innerloop Build and Test Build finished.
Details
Ubuntu16.04 arm64 Cross Checked no_tiered_compilation_innerloop Build and Test Build finished.
Details
@wip
WIP Ready for review
Details
Windows_NT arm Cross Debug Innerloop Build Build finished.
Details
Windows_NT arm64 Cross Debug Innerloop Build Build finished.
Details
Windows_NT x64 Checked CoreFX Tests Build finished.
Details
Windows_NT x64 Checked Innerloop Build and Test Build finished.
Details
Windows_NT x64 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Windows_NT x64 Formatting Build finished.
Details
Windows_NT x64 Release CoreFX Tests Build finished.
Details
Windows_NT x64 full_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x64 min_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x86 Checked Innerloop Build and Test Build finished.
Details
Windows_NT x86 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Windows_NT x86 Release Innerloop Build and Test Build finished.
Details
Windows_NT x86 full_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x86 min_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
license/cla All CLA requirements met.
Details
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
MichalStrehovsky added a commit to dotnet/corert that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
marek-safar added a commit to mono/mono that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub added a commit to dotnet/corefx that referenced this pull request Jan 11, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
baulig added a commit to mono/corefx that referenced this pull request Feb 5, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
(cherry picked from commit a938f91)
baulig added a commit to mono/corefx that referenced this pull request Feb 5, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
(cherry picked from commit a938f91)
@clairernovotny
Copy link
Member

@clairernovotny clairernovotny commented Feb 18, 2019

This PR is a bit problematic when trying to copy these types into a downlevel platform and support unification with type forwarders. The problem is twofold:

  1. The internal constructors. If I copy the type, I can't correctly type forward since the new type's ctor won't be visible.
  2. Adding methods to TaskExtensions. I can't forward certain methods; it would be much easier to add those to a new type that can be copied in full and typeforwarded on the netstandard2.1/netcoreapp3.0 version.

Can the ctor's be made public and the new methods from TaskExtension be split into its own type?

This is mainly because of 2, since I'd have to carry the method bodies in the 3.0 target, even if hidden by a reference assembly, and those implementation's can't create the instance of the struct.

I think the ctor visibility issue is moot if the two extension methods are split into a new type. Then I can copy the type and static class in full, and elide them in place with type forwarders on the 3.0 target.

/cc @bartdesmet @terrajobst

@stephentoub stephentoub deleted the stephentoub:withcancellation branch Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants