From e88e553cc9af78a89101f4d2c928064867922a38 Mon Sep 17 00:00:00 2001 From: neuecc Date: Fri, 26 Feb 2021 18:51:16 +0900 Subject: [PATCH] 2.2.1 --- .../WithCancellationTest.cs | 4 ++-- .../UniTask/Runtime/UniTaskExtensions.cs | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/UniTask.NetCoreTests/WithCancellationTest.cs b/src/UniTask.NetCoreTests/WithCancellationTest.cs index 3aeb42a..418b432 100644 --- a/src/UniTask.NetCoreTests/WithCancellationTest.cs +++ b/src/UniTask.NetCoreTests/WithCancellationTest.cs @@ -16,7 +16,7 @@ namespace NetCoreTests { CancellationTokenSource cts = new CancellationTokenSource(); - var v = await UniTask.Run(() => 10).IgnoreWhenCanceled(cts.Token); + var v = await UniTask.Run(() => 10).AttachExternalCancellation(cts.Token); v.Should().Be(10); } @@ -30,7 +30,7 @@ namespace NetCoreTests { await Task.Delay(TimeSpan.FromSeconds(1)); return 10; - }).IgnoreWhenCanceled(cts.Token); + }).AttachExternalCancellation(cts.Token); cts.Cancel(); diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs index c26125a..d330109 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs @@ -192,7 +192,7 @@ namespace Cysharp.Threading.Tasks /// /// Ignore task result when cancel raised first. /// - public static UniTask IgnoreWhenCanceled(this UniTask task, CancellationToken cancellationToken) + public static UniTask AttachExternalCancellation(this UniTask task, CancellationToken cancellationToken) { if (!cancellationToken.CanBeCanceled) { @@ -209,13 +209,13 @@ namespace Cysharp.Threading.Tasks return task; } - return new UniTask(new IgnoreWhenCanceledSource(task, cancellationToken), 0); + return new UniTask(new AttachExternalCancellationSource(task, cancellationToken), 0); } /// /// Ignore task result when cancel raised first. /// - public static UniTask IgnoreWhenCanceled(this UniTask task, CancellationToken cancellationToken) + public static UniTask AttachExternalCancellation(this UniTask task, CancellationToken cancellationToken) { if (!cancellationToken.CanBeCanceled) { @@ -232,10 +232,10 @@ namespace Cysharp.Threading.Tasks return task; } - return new UniTask(new IgnoreWhenCanceledSource(task, cancellationToken), 0); + return new UniTask(new AttachExternalCancellationSource(task, cancellationToken), 0); } - sealed class IgnoreWhenCanceledSource : IUniTaskSource + sealed class AttachExternalCancellationSource : IUniTaskSource { static readonly Action cancellationCallbackDelegate = CancellationCallback; @@ -243,7 +243,7 @@ namespace Cysharp.Threading.Tasks CancellationTokenRegistration tokenRegistration; UniTaskCompletionSourceCore core; - public IgnoreWhenCanceledSource(UniTask task, CancellationToken cancellationToken) + public AttachExternalCancellationSource(UniTask task, CancellationToken cancellationToken) { this.cancellationToken = cancellationToken; this.tokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallbackDelegate, this); @@ -269,7 +269,7 @@ namespace Cysharp.Threading.Tasks static void CancellationCallback(object state) { - var self = (IgnoreWhenCanceledSource)state; + var self = (AttachExternalCancellationSource)state; self.core.TrySetCanceled(self.cancellationToken); } @@ -294,7 +294,7 @@ namespace Cysharp.Threading.Tasks } } - sealed class IgnoreWhenCanceledSource : IUniTaskSource + sealed class AttachExternalCancellationSource : IUniTaskSource { static readonly Action cancellationCallbackDelegate = CancellationCallback; @@ -302,7 +302,7 @@ namespace Cysharp.Threading.Tasks CancellationTokenRegistration tokenRegistration; UniTaskCompletionSourceCore core; - public IgnoreWhenCanceledSource(UniTask task, CancellationToken cancellationToken) + public AttachExternalCancellationSource(UniTask task, CancellationToken cancellationToken) { this.cancellationToken = cancellationToken; this.tokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallbackDelegate, this); @@ -327,7 +327,7 @@ namespace Cysharp.Threading.Tasks static void CancellationCallback(object state) { - var self = (IgnoreWhenCanceledSource)state; + var self = (AttachExternalCancellationSource)state; self.core.TrySetCanceled(self.cancellationToken); }