Update to Go 1.18 and replace fnv-1a with xxhash (#158)
* Update modules and go 1.18 * Use xxhash instead of fnv-1a * Update go version in dockerfile and github workflow
This commit is contained in:
1 parent
c53d8f8a0d
commit
a95c028cb8
5 files changed
+104
-67
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
package pool
|
||||
|
||||
import (
|
||||
"github.com/segmentio/fasthash/fnv1a"
|
||||
"github.com/cespare/xxhash/v2"
|
||||
)
|
||||
|
||||
type WorkerPool struct {
|
||||
@@ -29,7 +29,7 @@ func New(maxWorkers int) *WorkerPool {
|
||||
}
|
||||
|
||||
func (p *WorkerPool) Submit(uid string, task func()) {
|
||||
idx := fnv1a.HashString64(uid) % uint64(p.maxWorkers)
|
||||
idx := xxhash.Sum64([]byte(uid)) % uint64(p.maxWorkers)
|
||||
if task != nil {
|
||||
p.taskQueue[idx] <- task
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user