Skip to content

Commit

Permalink
Ensure that the execution batching provider is disposed. (#7831)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Dec 16, 2024
1 parent 5ccdc28 commit 6747630
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/HotChocolate/Core/src/Fetching/BatchScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class BatchScheduler : IBatchHandler
private readonly List<Func<ValueTask>> _tasks = [];
private bool _dispatchOnSchedule;
private readonly List<EventHandler> _listeners = [];
private bool _disposed;

/// <inheritdoc />
public event EventHandler TaskEnqueued
Expand Down Expand Up @@ -219,4 +220,13 @@ private async Task DispatchOnEnqueue(Func<ValueTask> dispatch)
_semaphore.Release();
}
}

public void Dispose()
{
if (!_disposed)
{
_semaphore.Dispose();
_disposed = true;
}
}
}
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Fetching/IBatchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace HotChocolate.Fetching;
/// <summary>
/// The execution engine batch scheduler and dispatcher.
/// </summary>
public interface IBatchHandler : IBatchDispatcher, IBatchScheduler;
public interface IBatchHandler : IBatchDispatcher, IBatchScheduler, IDisposable;

0 comments on commit 6747630

Please sign in to comment.