From 0bea0e1418d3e632e1d5e2334ed39a31aa1892d0 Mon Sep 17 00:00:00 2001 From: hui Date: Thu, 13 Jan 2022 15:38:53 +0800 Subject: [PATCH] AvailableWorkers --- workers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/workers.go b/workers.go index dc36433..c017407 100644 --- a/workers.go +++ b/workers.go @@ -32,6 +32,7 @@ type Runner interface { Start() Runner Stop() chan error Wait() error + AvailableWorkers() int64 } type runner struct { @@ -199,6 +200,11 @@ func (r *runner) waitForDrain() { } } +// AvailableWorkers . +func (r *runner) AvailableWorkers() int64 { + return r.numWorkers - int64(len(r.limiter)) +} + // startWork Runs the before function and starts processing until one of three things happen. // 1. A term signal is received or cancellation of context. // 2. Stop function is called.