Skip to content

Commit 6747630

Browse files
committed
Ensure that the execution batching provider is disposed. (#7831)
1 parent 5ccdc28 commit 6747630

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/HotChocolate/Core/src/Fetching/BatchScheduler.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public sealed class BatchScheduler : IBatchHandler
1717
private readonly List<Func<ValueTask>> _tasks = [];
1818
private bool _dispatchOnSchedule;
1919
private readonly List<EventHandler> _listeners = [];
20+
private bool _disposed;
2021

2122
/// <inheritdoc />
2223
public event EventHandler TaskEnqueued
@@ -219,4 +220,13 @@ private async Task DispatchOnEnqueue(Func<ValueTask> dispatch)
219220
_semaphore.Release();
220221
}
221222
}
223+
224+
public void Dispose()
225+
{
226+
if (!_disposed)
227+
{
228+
_semaphore.Dispose();
229+
_disposed = true;
230+
}
231+
}
222232
}

src/HotChocolate/Core/src/Fetching/IBatchHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace HotChocolate.Fetching;
55
/// <summary>
66
/// The execution engine batch scheduler and dispatcher.
77
/// </summary>
8-
public interface IBatchHandler : IBatchDispatcher, IBatchScheduler;
8+
public interface IBatchHandler : IBatchDispatcher, IBatchScheduler, IDisposable;

0 commit comments

Comments
 (0)