Simplify worker num with min
This commit is contained in:
parent
c265e42220
commit
f9b3deaff2
1 changed files with 1 additions and 3 deletions
|
|
@ -147,10 +147,8 @@ const defaultNumWorkers = 10
|
||||||
func (job *workerPoolJob[I, O]) withWorkers(workers int) *workerPoolJob[I, O] {
|
func (job *workerPoolJob[I, O]) withWorkers(workers int) *workerPoolJob[I, O] {
|
||||||
if workers == 0 {
|
if workers == 0 {
|
||||||
job.workers = defaultNumWorkers
|
job.workers = defaultNumWorkers
|
||||||
} else if workers > len(job.data) {
|
|
||||||
job.workers = len(job.data)
|
|
||||||
} else {
|
} else {
|
||||||
job.workers = workers
|
job.workers = min(workers, len(job.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
return job
|
return job
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue