MCPcopy Create free account
hub / github.com/LockGit/gochat / Bucket

Method Bucket

connect/server.go:45–49  ·  view source on GitHub ↗

reduce lock competition, use google city hash insert to different bucket

(userId int)

Source from the content-addressed store, hash-verified

43
44//reduce lock competition, use google city hash insert to different bucket
45func (s *Server) Bucket(userId int) *Bucket {
46 userIdStr := fmt.Sprintf("%d", userId)
47 idx := tools.CityHash32([]byte(userIdStr), uint32(len(userIdStr))) % s.bucketIdx
48 return s.Buckets[idx]
49}
50
51func (s *Server) writePump(ch *Channel, c *Connect) {
52 //PingPeriod default eq 54s

Callers 3

readPumpMethod · 0.95
PushSingleMsgMethod · 0.80
readDataFromTcpMethod · 0.80

Calls 1

CityHash32Function · 0.92

Tested by

no test coverage detected