multimutex: remove HashMutex, make Mutex type a type param

In this commit, we eliminate some code duplication by removing the old
`HashMutex` struct as it just duplicates all the code with a different
type (uint64 and hash). We then make the main Mutex struct take a type
param, so the key can be parametrized when the struct is instantiated.
This commit is contained in:
Olaoluwa Osuntokun
2023-06-01 17:38:37 -07:00
parent f9d4600ff8
commit a7d6826f60
7 changed files with 45 additions and 142 deletions

View File

@@ -93,14 +93,14 @@ type networkResultStore struct {
// paymentIDMtx is a multimutex used to make sure the database and
// result subscribers map is consistent for each payment ID in case of
// concurrent callers.
paymentIDMtx *multimutex.Mutex
paymentIDMtx *multimutex.Mutex[uint64]
}
func newNetworkResultStore(db kvdb.Backend) *networkResultStore {
return &networkResultStore{
backend: db,
results: make(map[uint64][]chan *networkResult),
paymentIDMtx: multimutex.NewMutex(),
paymentIDMtx: multimutex.NewMutex[uint64](),
}
}