blob: 0c64dcc4cb71c33b3adf44a0a4959ab33fcc7e4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package mountmanager
import "sync"
// keyMutex provides a lock per key to serialize operations per volume.
type keyMutex struct {
mutexes sync.Map
}
func newKeyMutex() *keyMutex {
return &keyMutex{}
}
func (km *keyMutex) get(key string) *sync.Mutex {
m, _ := km.mutexes.LoadOrStore(key, &sync.Mutex{})
return m.(*sync.Mutex)
}
func (km *keyMutex) delete(key string) {
km.mutexes.Delete(key)
}
|