feat: verify Tornado PGM cut sequence

This commit is contained in:
2026-07-10 16:05:06 +09:00
parent 930424b752
commit d12a5d8095
15 changed files with 4344 additions and 74 deletions

View File

@@ -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;
}