From e505009f4331a527f0bc25c162e421490eeff8df Mon Sep 17 00:00:00 2001 From: Anton Lapounov Date: Sat, 24 Mar 2018 15:48:47 -0700 Subject: [PATCH] Rename CancellationTokenRegistration.TryDeregister method to Unregister. (#17194) Reflects CoreRT change https://github.com/dotnet/corert/pull/5612. --- src/mscorlib/src/System/Threading/CancellationToken.cs | 8 ++++---- .../src/System/Threading/CancellationTokenRegistration.cs | 10 +++++----- src/mscorlib/src/System/Threading/CancellationTokenSource.cs | 2 +- src/mscorlib/src/System/Threading/ManualResetEventSlim.cs | 4 ++-- src/mscorlib/src/System/Threading/SemaphoreSlim.cs | 2 +- src/mscorlib/src/System/Threading/Tasks/Task.cs | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/mscorlib/src/System/Threading/CancellationToken.cs b/src/mscorlib/src/System/Threading/CancellationToken.cs index 9766ca2..886210c 100644 --- a/src/mscorlib/src/System/Threading/CancellationToken.cs +++ b/src/mscorlib/src/System/Threading/CancellationToken.cs @@ -130,7 +130,7 @@ namespace System.Threading /// /// The delegate to be executed when the CancellationToken is canceled. /// The instance that can - /// be used to deregister the callback. + /// be used to unregister the callback. /// is null. public CancellationTokenRegistration Register(Action callback) => Register( @@ -159,7 +159,7 @@ namespace System.Threading /// the current SynchronizationContext and use it /// when invoking the . /// The instance that can - /// be used to deregister the callback. + /// be used to unregister the callback. /// is null. public CancellationTokenRegistration Register(Action callback, bool useSynchronizationContext) => Register( @@ -186,7 +186,7 @@ namespace System.Threading /// The delegate to be executed when the CancellationToken is canceled. /// The state to pass to the when the delegate is invoked. This may be null. /// The instance that can - /// be used to deregister the callback. + /// be used to unregister the callback. /// is null. public CancellationTokenRegistration Register(Action callback, object state) => Register(callback, state, useSyncContext: false, useExecutionContext: true); @@ -212,7 +212,7 @@ namespace System.Threading /// the current SynchronizationContext and use it /// when invoking the . /// The instance that can - /// be used to deregister the callback. + /// be used to unregister the callback. /// is null. /// The associated CancellationTokenSource has been disposed. diff --git a/src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs b/src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs index 2b56bf7..3c964a9 100644 --- a/src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs +++ b/src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs @@ -24,8 +24,8 @@ namespace System.Threading /// /// Disposes of the registration and unregisters the target callback from the associated /// CancellationToken. - /// If the target callback is currently executing this method will wait until it completes, except - /// in the degenerate cases where a callback method deregisters itself. + /// If the target callback is currently executing, this method will wait until it completes, except + /// in the degenerate cases where a callback method unregisters itself. /// public void Dispose() { @@ -47,7 +47,7 @@ namespace System.Threading /// Disposes of the registration and unregisters the target callback from the associated /// CancellationToken. /// - internal bool TryDeregister() // corefx currently has an InternalsVisibleTo dependency on this + internal bool Unregister() // corefx currently has an InternalsVisibleTo dependency on this { CancellationTokenSource.CallbackNode node = _node; return node != null && node.Partition.Unregister(_id, node); @@ -62,8 +62,8 @@ namespace System.Threading // 1. If we are called in the context of an executing callback, no need to wait (determined by tracking callback-executor threadID) // - if the currently executing callback is this CTR, then waiting would deadlock. (We choose to return rather than deadlock) // - if not, then this CTR cannot be the one executing, hence no need to wait - // 2. If deregistration failed, and we are on a different thread, then the callback may be running under control of cts.Cancel() - // => poll until cts.ExecutingCallback is not the one we are trying to deregister. + // 2. If unregistration failed, and we are on a different thread, then the callback may be running under control of cts.Cancel() + // => poll until cts.ExecutingCallback is not the one we are trying to unregister. CancellationTokenSource source = _node.Partition.Source; if (source.IsCancellationRequested && // Running callbacks has commenced. !source.IsCancellationCompleted && // Running callbacks hasn't finished. diff --git a/src/mscorlib/src/System/Threading/CancellationTokenSource.cs b/src/mscorlib/src/System/Threading/CancellationTokenSource.cs index 07b9328..3b47cf5 100644 --- a/src/mscorlib/src/System/Threading/CancellationTokenSource.cs +++ b/src/mscorlib/src/System/Threading/CancellationTokenSource.cs @@ -386,7 +386,7 @@ namespace System.Threading { if (disposing && !_disposed) { - // We specifically tolerate that a callback can be deregistered + // We specifically tolerate that a callback can be unregistered // after the CTS has been disposed and/or concurrently with cts.Dispose(). // This is safe without locks because Dispose doesn't interact with values // in the callback partitions, only nulling out the ref to existing partitions. diff --git a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs index d276771..d0a8d34 100644 --- a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs @@ -575,7 +575,7 @@ namespace System.Threading // Now enter the lock and wait. EnsureLockObjectCreated(); - // We must register and deregister the token outside of the lock, to avoid deadlocks. + // We must register and unregister the token outside of the lock, to avoid deadlocks. using (cancellationToken.InternalRegisterWithoutEC(s_cancellationTokenCallback, this)) { lock (m_lock) @@ -629,7 +629,7 @@ namespace System.Threading } } } - } // automatically disposes (and deregisters) the callback + } // automatically disposes (and unregisters) the callback return true; //done. The wait was satisfied. } diff --git a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs b/src/mscorlib/src/System/Threading/SemaphoreSlim.cs index c075a6d..997dbb9 100644 --- a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs +++ b/src/mscorlib/src/System/Threading/SemaphoreSlim.cs @@ -342,7 +342,7 @@ namespace System.Threading bool lockTaken = false; //Register for cancellation outside of the main lock. - //NOTE: Register/deregister inside the lock can deadlock as different lock acquisition orders could + //NOTE: Register/unregister inside the lock can deadlock as different lock acquisition orders could // occur for (1)this.m_lockObj and (2)cts.internalLock CancellationTokenRegistration cancellationTokenRegistration = cancellationToken.InternalRegisterWithoutEC(s_cancellationTokenCanceledEventHandler, this); try diff --git a/src/mscorlib/src/System/Threading/Tasks/Task.cs b/src/mscorlib/src/System/Threading/Tasks/Task.cs index e4ca132..6d4ddf8 100644 --- a/src/mscorlib/src/System/Threading/Tasks/Task.cs +++ b/src/mscorlib/src/System/Threading/Tasks/Task.cs @@ -275,11 +275,11 @@ namespace System.Threading.Tasks } /// - /// Checks if we registered a CT callback during construction, and deregisters it. + /// Checks if we registered a CT callback during construction, and unregisters it. /// This should be called when we know the registration isn't useful anymore. Specifically from Finish() if the task has completed /// successfully or with an exception. /// - internal void DeregisterCancellationCallback() + internal void UnregisterCancellationCallback() { if (m_cancellationRegistration != null) { @@ -2160,7 +2160,7 @@ namespace System.Threading.Tasks if (cp != null) { cp.SetCompleted(); - cp.DeregisterCancellationCallback(); + cp.UnregisterCancellationCallback(); } // ready to run continuations and notify parent. @@ -3196,7 +3196,7 @@ namespace System.Threading.Tasks if (cp != null) { cp.SetCompleted(); - cp.DeregisterCancellationCallback(); + cp.UnregisterCancellationCallback(); } if (AsyncCausalityTracer.LoggingOn) -- 2.7.4