reduce lock competition, use google city hash insert to different bucket
(userId int)
| 43 | |
| 44 | //reduce lock competition, use google city hash insert to different bucket |
| 45 | func (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 | |
| 51 | func (s *Server) writePump(ch *Channel, c *Connect) { |
| 52 | //PingPeriod default eq 54s |
no test coverage detected