Reflects CoreRT change https://github.com/dotnet/corert/pull/5612.
/// </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(
/// 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(
/// <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);
/// 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>
/// <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()
{
/// 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);
// 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.
{
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.
// 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)
}
}
}
- } // automatically disposes (and deregisters) the callback
+ } // automatically disposes (and unregisters) the callback
return true; //done. The wait was satisfied.
}
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
}
/// <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)
{
if (cp != null)
{
cp.SetCompleted();
- cp.DeregisterCancellationCallback();
+ cp.UnregisterCancellationCallback();
}
// ready to run continuations and notify parent.
if (cp != null)
{
cp.SetCompleted();
- cp.DeregisterCancellationCallback();
+ cp.UnregisterCancellationCallback();
}
if (AsyncCausalityTracer.LoggingOn)