Rename CancellationTokenRegistration.TryDeregister method to Unregister. (#17194)
authorAnton Lapounov <anton.lapounov@microsoft.com>
Sat, 24 Mar 2018 22:48:47 +0000 (15:48 -0700)
committerJan Kotas <jkotas@microsoft.com>
Sat, 24 Mar 2018 22:48:47 +0000 (15:48 -0700)
Reflects CoreRT change https://github.com/dotnet/corert/pull/5612.

src/mscorlib/src/System/Threading/CancellationToken.cs
src/mscorlib/src/System/Threading/CancellationTokenRegistration.cs
src/mscorlib/src/System/Threading/CancellationTokenSource.cs
src/mscorlib/src/System/Threading/ManualResetEventSlim.cs
src/mscorlib/src/System/Threading/SemaphoreSlim.cs
src/mscorlib/src/System/Threading/Tasks/Task.cs

index 9766ca2..886210c 100644 (file)
@@ -130,7 +130,7 @@ namespace System.Threading
         /// </remarks>
         /// <param name="callback">The delegate to be executed when the <see cref="T:System.Threading.CancellationToken">CancellationToken</see> is canceled.</param>
         /// <returns>The <see cref="T:System.Threading.CancellationTokenRegistration"/> instance that can 
-        /// be used to deregister the callback.</returns>
+        /// be used to unregister the callback.</returns>
         /// <exception cref="T:System.ArgumentNullException"><paramref name="callback"/> is null.</exception>
         public CancellationTokenRegistration Register(Action callback) =>
             Register(
@@ -159,7 +159,7 @@ namespace System.Threading
         /// the current <see cref="T:System.Threading.SynchronizationContext">SynchronizationContext</see> and use it
         /// when invoking the <paramref name="callback"/>.</param>
         /// <returns>The <see cref="T:System.Threading.CancellationTokenRegistration"/> instance that can 
-        /// be used to deregister the callback.</returns>
+        /// be used to unregister the callback.</returns>
         /// <exception cref="T:System.ArgumentNullException"><paramref name="callback"/> is null.</exception>
         public CancellationTokenRegistration Register(Action callback, bool useSynchronizationContext) =>
             Register(
@@ -186,7 +186,7 @@ namespace System.Threading
         /// <param name="callback">The delegate to be executed when the <see cref="T:System.Threading.CancellationToken">CancellationToken</see> is canceled.</param>
         /// <param name="state">The state to pass to the <paramref name="callback"/> when the delegate is invoked.  This may be null.</param>
         /// <returns>The <see cref="T:System.Threading.CancellationTokenRegistration"/> instance that can 
-        /// be used to deregister the callback.</returns>
+        /// be used to unregister the callback.</returns>
         /// <exception cref="T:System.ArgumentNullException"><paramref name="callback"/> is null.</exception>
         public CancellationTokenRegistration Register(Action<object> callback, object state) =>
             Register(callback, state, useSyncContext: false, useExecutionContext: true);
@@ -212,7 +212,7 @@ namespace System.Threading
         /// the current <see cref="T:System.Threading.SynchronizationContext">SynchronizationContext</see> and use it
         /// when invoking the <paramref name="callback"/>.</param>
         /// <returns>The <see cref="T:System.Threading.CancellationTokenRegistration"/> instance that can 
-        /// be used to deregister the callback.</returns>
+        /// be used to unregister the callback.</returns>
         /// <exception cref="T:System.ArgumentNullException"><paramref name="callback"/> is null.</exception>
         /// <exception cref="T:System.ObjectDisposedException">The associated <see
         /// cref="T:System.Threading.CancellationTokenSource">CancellationTokenSource</see> has been disposed.</exception>
index 2b56bf7..3c964a9 100644 (file)
@@ -24,8 +24,8 @@ namespace System.Threading
         /// <summary>
         /// Disposes of the registration and unregisters the target callback from the associated 
         /// <see cref="T:System.Threading.CancellationToken">CancellationToken</see>.
-        /// 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.
         /// </summary>
         public void Dispose()
         {
@@ -47,7 +47,7 @@ namespace System.Threading
         /// Disposes of the registration and unregisters the target callback from the associated 
         /// <see cref="T:System.Threading.CancellationToken">CancellationToken</see>.
         /// </summary>
-        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.
index 07b9328..3b47cf5 100644 (file)
@@ -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.
index d276771..d0a8d34 100644 (file)
@@ -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.
         }
index c075a6d..997dbb9 100644 (file)
@@ -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
index e4ca132..6d4ddf8 100644 (file)
@@ -275,11 +275,11 @@ namespace System.Threading.Tasks
             }
 
             /// <summary>
-            /// 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.
             /// </summary>
-            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)