Skip to content

Commit 4fafcfa

Browse files
committed
fix comments
1 parent 8363d46 commit 4fafcfa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

dataloader.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ func (l *Loader[K, V]) Load(originalContext context.Context, key K) Thunk[V] {
265265
l.count++
266266
// if we hit our limit, force the batch to start
267267
if l.count == l.batchCap {
268+
// end/flush the batcher synchronously here because another call to Load
269+
// may concurrently happen and needs to go to a new batcher.
268270
l.flush()
269271
}
270272
}
@@ -276,9 +278,6 @@ func (l *Loader[K, V]) Load(originalContext context.Context, key K) Thunk[V] {
276278
// flush() is a helper that runs whatever batched items there are immediately.
277279
// it must be called by code protected by a l.batchLock.Lock()
278280
func (l *Loader[K, V]) flush() {
279-
// if we need to keep track of the count (max batch), then do so.
280-
// end the batcher synchronously here because another call to Load
281-
// may concurrently happen and needs to go to a new batcher.
282281
l.curBatcher.end()
283282

284283
// end the sleeper for the current batcher.

0 commit comments

Comments
 (0)