Affinity is a tool for goroutine cpu core affinity binding.
funcprocessUnit(cpuIDint) chan*string {
ch:=make(chan*string, 1000)
gofunc() {
affinity.SetAffinity(cpuID)
proc:=poly.NewProcessor()
for {
proc.Process(<-ch)
}
}()
returnch
}calling affinity.SetAffinity in an goroutine could bind the goroutine on operation system thread (M) and binding the thread on specific cpu core.
MIT License