Skip to content

Commit 0998340

Browse files
kaworurolinh
authored andcommitted
doc: explicit that result callback cannot call Submit() nor Close()
Signed-off-by: Alexandre Perrin <alex@isovalent.com>
1 parent d7b7562 commit 0998340

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

workerpool.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ type Option func(*WorkerPool)
4848
// - [Drain] will return [ErrCallbackSet] instead of collecting results
4949
// - Results are processed immediately upon completion, avoiding memory
5050
// buildup
51-
// - The callback fn may be invoked concurrently from multiple goroutines
5251
//
53-
// The callback fn must be safe for concurrent use.
52+
// The callback fn is invoked from the worker goroutines.
53+
// This has a few implications:
54+
// 1. fn must be safe for concurrent use.
55+
// 2. fn must NOT call [Submit] nor [Close] as it will lead to a deadlock.
56+
//
5457
// WithResultCallback panics if fn is nil.
5558
func WithResultCallback(fn func(Result)) Option {
5659
// TODO(v2): New/NewWithContext should return an error so that option

0 commit comments

Comments
 (0)