[chore]: Bump codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1 (#1428)

Bumps codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1.

---
updated-dependencies:
- dependency-name: codeberg.org/gruf/go-runners
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-02-06 08:08:22 +00:00 committed by GitHub
commit 0a9874329d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 40 deletions

View file

@ -67,20 +67,14 @@ func (pool *WorkerPool) Start(workers int, queue int) bool {
go func() {
defer wait.Done()
// Run worker function.
for !worker_run(ctx, fns) {
// retry on panic
// Run worker function (retry on panic)
for !worker_run(CancelCtx(ctx), fns) {
}
}()
}
// Set GC finalizer to stop pool on dealloc.
runtime.SetFinalizer(pool, func(pool *WorkerPool) {
_ = pool.svc.Stop()
})
// Wait on ctx
<-ctx.Done()
<-ctx
// Drain function queue.
//
@ -110,6 +104,16 @@ func (pool *WorkerPool) Stop() bool {
return pool.svc.Stop()
}
// Running returns if WorkerPool management loop is running (i.e. NOT stopped / stopping).
func (pool *WorkerPool) Running() bool {
return pool.svc.Running()
}
// Done returns a channel that's closed when WorkerPool.Stop() is called. It is the same channel provided to the currently running worker functions.
func (pool *WorkerPool) Done() <-chan struct{} {
return pool.svc.Done()
}
// Enqueue will add provided WorkerFunc to the queue to be performed when there is a free worker.
// This will block until function is queued or pool is stopped. In all cases, the WorkerFunc will be
// executed, with the state of the pool being indicated by <-ctx.Done() of the passed ctx.