/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
os/grpool/grpool_supervisor.go
30 строк
725 B
John Guo
add supervisor for package grpool (#2252)
08 ноя 2022, 14:00
Не верифицирован
08 ноя 2022, 14:00
b000aa3
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. package grpool import ( "context" "github.com/gogf/gf/v2/os/gtimer" ) // supervisor checks the job list and fork new worker goroutine to handle the job // if there are jobs but no workers in pool. func (p *Pool) supervisor(ctx context.Context) { if p.IsClosed() { gtimer.Exit() } if p.list.Size() > 0 && p.count.Val() == 0 { var number = p.list.Size() if p.limit > 0 { number = p.limit } for i := 0; i < number; i++ { p.checkAndFork() } } }