Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
40 lines
803 B
Go
40 lines
803 B
Go
/*Package parallel provides helper functions for the dispatching of parallel jobs.*/
|
|
package parallel
|
|
|
|
import (
|
|
"runtime"
|
|
"sync"
|
|
)
|
|
|
|
func init() {
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
}
|
|
|
|
// Line dispatches a parameter fn into multiple goroutines by splitting the parameter length
|
|
// by the number of available CPUs and assigning the length parts into each fn.
|
|
func Line(length int, fn func(start, end int)) {
|
|
procs := runtime.GOMAXPROCS(0)
|
|
counter := length
|
|
partSize := length / procs
|
|
if procs <= 1 || partSize <= procs {
|
|
fn(0, length)
|
|
} else {
|
|
var wg sync.WaitGroup
|
|
for counter > 0 {
|
|
start := counter - partSize
|
|
end := counter
|
|
if start < 0 {
|
|
start = 0
|
|
}
|
|
counter -= partSize
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
fn(start, end)
|
|
}()
|
|
}
|
|
|
|
wg.Wait()
|
|
}
|
|
}
|