(key, identifier string)
| 44 | var _ Locker = &keyMutex{} |
| 45 | |
| 46 | func (k *keyMutex) TryLock(key, identifier string) bool { |
| 47 | mux, _ := k.muxes.LoadOrStore(key, &lockWithIdent{ |
| 48 | mux: sync.Mutex{}, |
| 49 | }) |
| 50 | keyMux := mux.(*lockWithIdent) |
| 51 | locked := keyMux.mux.TryLock() |
| 52 | if locked { |
| 53 | keyMux.ident = identifier |
| 54 | keyMux.isLocked.Store(true) |
| 55 | } |
| 56 | |
| 57 | return locked |
| 58 | } |
| 59 | |
| 60 | func (k *keyMutex) Lock(key, identifier string) { |
| 61 | mux, _ := k.muxes.LoadOrStore(key, &lockWithIdent{ |
no test coverage detected