gorgonia.org/gorgonia@v0.9.17/concurrency.go (about) 1 package gorgonia 2 3 import "runtime" 4 5 const ( 6 // defaultBlockSize indicates the default size to chunk an array. 7 defaultBlockSize = 64 8 9 // minParallelBlocks indicates how many blocks an array must be split up into 10 // before we decide to parallelize 11 minParallelBlocks = 4 12 ) 13 14 // workersChan creates a channel that is limited by the number of processor cores. 15 // To signal that a processor core is being used: 16 // ch <- struct{}{} 17 // When done: 18 // <- ch 19 func workersChan() chan struct{} { return make(chan struct{}, runtime.GOMAXPROCS(0)) } 20 21 // it's just a generic ceiling function. Added here to avoid mixing with any potential ceilInt operation 22 func calcBlocks(n, maxThreads int) int { 23 return (n + maxThreads - 1) / maxThreads 24 }