mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
20 lines
267 B
Go
20 lines
267 B
Go
package datastore
|
|
|
|
import (
|
|
"strconv"
|
|
"sync"
|
|
)
|
|
|
|
type HashLock [4096]sync.RWMutex
|
|
|
|
func (h *HashLock) Get(hash string) *sync.RWMutex {
|
|
if len(hash) < 3 {
|
|
return nil
|
|
}
|
|
i, err := strconv.ParseInt(hash[0:3], 16, 0)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return &h[i]
|
|
}
|