Skip to content

Commit 8f3b218

Browse files
try to use go1.25 waitgroup logic
1 parent d4b1e10 commit 8f3b218

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

modules/queue/workergroup.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ func resetIdleTicker(t *time.Ticker, dur time.Duration) {
153153

154154
// doStartNewWorker starts a new worker for the queue, the worker reads from worker's channel and handles the items.
155155
func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
156-
wp.wg.Add(1)
157-
go func() {
158-
defer wp.wg.Done()
156+
wp.wg.Go(func() {
159157
log.Debug("Queue %q starts new worker", q.GetName())
160158
defer log.Debug("Queue %q stops idle worker", q.GetName())
161159

@@ -190,7 +188,7 @@ func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) {
190188
q.workerNumMu.Unlock()
191189
}
192190
}
193-
}()
191+
})
194192
}
195193

196194
// doFlush flushes the queue: it tries to read all items from the queue and handles them.

0 commit comments

Comments
 (0)