Keep pool running through worker failures until explicit close

This commit is contained in:
2026-10-20 22:04:17 +08:00
parent 44cadc6d26
commit 24c7ab3a65
3 changed files with 272 additions and 100 deletions

View File

@@ -26,12 +26,12 @@ After a task finishes, a worker exits immediately only when `total > min` and
the number of *other* idle workers is greater than `min/2`. There is no idle
timeout. A task panic is logged and that worker continues with later tasks.
Tasks should return normally or panic. A panic in worker scheduling code is
logged and terminates that worker without replacement. `runtime.Goexit` from a
task has the same worker-exit behavior. If the last worker exits abnormally,
queued accepted tasks are discarded so `Close` can return; if other workers
remain, they keep the queue. Call `Close` from outside pool tasks so it does
not wait for itself.
Only `Close` shuts down the pool. A task panic is logged and the same worker
continues. A worker scheduling panic or `runtime.Goexit` terminates that
worker; the pool starts a replacement as needed, and accepted queued tasks
remain available even while `Close` is draining. The task that panicked or
called `runtime.Goexit` is not retried. Call `Close` from outside pool tasks so
it does not wait for itself.
A task may submit another task to the same pool. If all workers block submitting
to a full queue, the caller must resolve that deadlock in its task logic.