feat: verify Tornado PGM cut sequence
This commit is contained in:
@@ -14,7 +14,8 @@ internal interface IStaDispatcher : IAsyncDisposable
|
||||
TimeSpan timeout,
|
||||
CancellationToken cancellationToken,
|
||||
Action<T>? abandonedResultCleanup = null,
|
||||
Action? abandonedFailureCleanup = null);
|
||||
Action? abandonedFailureCleanup = null,
|
||||
Action? preventFutureDispatch = null);
|
||||
}
|
||||
|
||||
internal interface IStaDispatcherFactory
|
||||
@@ -75,7 +76,8 @@ internal sealed class StaDispatcher : IStaDispatcher
|
||||
TimeSpan timeout,
|
||||
CancellationToken cancellationToken,
|
||||
Action<T>? abandonedResultCleanup = null,
|
||||
Action? abandonedFailureCleanup = null)
|
||||
Action? abandonedFailureCleanup = null,
|
||||
Action? preventFutureDispatch = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(callback);
|
||||
if (timeout <= TimeSpan.Zero)
|
||||
@@ -110,7 +112,7 @@ internal sealed class StaDispatcher : IStaDispatcher
|
||||
return await completion.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (item.TryTimeout())
|
||||
if (item.TryTimeout(preventFutureDispatch))
|
||||
{
|
||||
Quarantine();
|
||||
}
|
||||
@@ -295,7 +297,7 @@ internal sealed class StaDispatcher : IStaDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryTimeout()
|
||||
public bool TryTimeout(Action? preventFutureDispatch)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@@ -307,6 +309,15 @@ internal sealed class StaDispatcher : IStaDispatcher
|
||||
|
||||
if (Interlocked.CompareExchange(ref _executionState, 2, state) == state)
|
||||
{
|
||||
try
|
||||
{
|
||||
preventFutureDispatch?.Invoke();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A timeout must still complete and quarantine the dispatcher.
|
||||
}
|
||||
|
||||
TimeoutCore();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user