From e33763d1883122945866568f6fe88220ef141a26 Mon Sep 17 00:00:00 2001 From: Alexandre Perrin Date: Fri, 3 Apr 2026 11:36:29 +0200 Subject: [PATCH] doc: explicit that result callback cannot call Submit() nor Close() Signed-off-by: Alexandre Perrin --- workerpool.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/workerpool.go b/workerpool.go index 9ea8271..55caf90 100644 --- a/workerpool.go +++ b/workerpool.go @@ -48,9 +48,12 @@ type Option func(*WorkerPool) // - [Drain] will return [ErrCallbackSet] instead of collecting results // - Results are processed immediately upon completion, avoiding memory // buildup -// - The callback fn may be invoked concurrently from multiple goroutines // -// The callback fn must be safe for concurrent use. +// The callback fn is invoked from the worker goroutines. +// This has a few implications: +// 1. fn must be safe for concurrent use. +// 2. fn must NOT call [Submit] nor [Close] as it will lead to a deadlock. +// // WithResultCallback panics if fn is nil. func WithResultCallback(fn func(Result)) Option { // TODO(v2): New/NewWithContext should return an error so that option