// Returns a mutex for the given key, no guarantee of its lock status
189096
func (m *MutexKV) get(key string) *sync.Mutex {
	m.lock.Lock()
	defer m.lock.Unlock()
	mutex, ok := m.store[key]
	if !ok {
		mutex = &sync.Mutex{}
		m.store[key] = mutex
	}
	return mutex
}
893884
func (s *Store) Lock() (err error) {
	s.mtx.Lock()
	defer s.mtx.Unlock()

	if s.flags.watchingOnly {
		return ErrWatchingOnly
	}

	// Remove clear text passphrase from key store.
	if s.isLocked() {
		err = ErrLocked
	} else {
		zero(s.passphrase)
		s.passphrase = nil
		zero(s.secret)
		s.secret = nil
	}

	// Remove clear text private keys from all address entries.
	for _, addr := range s.addrMap {
		if baddr, ok := addr.(*btcAddress); ok {
			_ = baddr.lock()
		}
	}

	return err
}
1316917
func (m *Mutex) Unlock() bool {
	m.nodem.Lock()
	defer m.nodem.Unlock()

	value := m.value
	if value == "" {
		panic("redsync: unlock of unlocked mutex")
	}

	m.value = ""
	m.until = time.Unix(0, 0)

	n := 0
	for _, node := range m.nodes {
		if node == nil {
			continue
		}

		conn := node.Get()
		status, err := delScript.Do(conn, m.Name, value)
		conn.Close()
		if err != nil {
			continue
		}
		if status == 0 {
			continue
		}
		n++
	}
	if n >= m.Quorum {
		return true
	}
	return false
}
609560
func (policies ACLPolicies) HashKey() string {
	cacheKeyHash, err := blake2b.New256(nil)
	if err != nil {
		panic(err)
	}
	for _, policy := range policies {
		cacheKeyHash.Write([]byte(policy.ID))
		// including the modify index prevents a policy set from being
		// cached if one of the policies has changed
		binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex)
	}
	return fmt.Sprintf("%x", cacheKeyHash.Sum(nil))
}
571304
func (pm *ProducerMessage) GetKey() string {
	key, _ := pm.Key.Encode()
	return string(key)
}
828525
func (mutex *Mutex) Unlock() error {
	ret := int(C.SDL_UnlockMutex(mutex.cptr()))
	if ret != 0 {
		return GetError()
	}
	return nil
}
336243
func (s *MemoryStore) Get(key string) (interface{}, error) {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	if v, ok := s.store[key]; ok {
		return v, nil
	}

	return nil, ErrNotExist
}
876099
func (km *KeyManager) Get(k Key) KeyState {
	km.mutex.RLock()
	ks := km.mapper[k]
	km.mutex.RUnlock()

	return ks
}
792759
func (ri *readerOffsetsIterator) Key(b *faultBuffer) []byte {
	if ri.ks.key == nil {
		ri.ks.key = b.access(ri.KeyOffset(), uint32(ri.Length(b)))
	}
	return ri.ks.key
}
830901
func (c *Etcd2Lock) getSemaphoreKey() (string, string, uint64, error) {
	// Get the list of waiters in order to see if we are next.
	getOpts := &client.GetOptions{
		Recursive: false,
		Sort:      true,
	}
	response, err := c.kAPI.Get(context.Background(), c.semaphoreDirKey, getOpts)
	if err != nil {
		return "", "", 0, err
	}

	// Make sure the list isn't empty.
	if response.Node.Nodes.Len() == 0 {
		return "", "", response.Index, nil
	}
	return response.Node.Nodes[0].Key, response.Node.Nodes[0].Value, response.Index, nil
}
1342621
func (d *MutexDatastore) Get(key ds.Key) (value []byte, err error) {
	d.RLock()
	defer d.RUnlock()
	return d.child.Get(key)
}
45655
func (s *Filesystem) Lock(info *LockInfo) (string, error) {
	defer s.mutex()()

	if s.stateFileOut == nil {
		if err := s.createStateFiles(); err != nil {
			return "", err
		}
	}

	if s.lockID != "" {
		return "", fmt.Errorf("state %q already locked", s.stateFileOut.Name())
	}

	if err := s.lock(); err != nil {
		info, infoErr := s.lockInfo()
		if infoErr != nil {
			err = multierror.Append(err, infoErr)
		}

		lockErr := &LockError{
			Info: info,
			Err:  err,
		}

		return "", lockErr
	}

	s.lockID = info.ID
	return s.lockID, s.writeLockInfo(info)
}
1244212
func (pc *P) WithMutex(key interface{}, fn func()) {
	// Get a lock for this config key, and increment its reference.
	me := pc.getConfigLock(key)
	defer pc.decRef(me, key)

	// Hold this lock's mutex and call "fn".
	me.Lock()
	defer me.Unlock()

	fn()
}
600123
func (s *GlobalStore) lock(addr common.Address, key []byte) (unlock func(), err error) {
	start := time.Now()
	nodeLockKey := addr.Hex()
	for {
		_, loaded := s.nodesLocks.LoadOrStore(nodeLockKey, struct{}{})
		if !loaded {
			break
		}
		time.Sleep(lockCheckDelay)
		if time.Since(start) > lockTimeout {
			return nil, errLockTimeout
		}
	}
	start = time.Now()
	keyLockKey := common.Bytes2Hex(key)
	for {
		_, loaded := s.keysLocks.LoadOrStore(keyLockKey, struct{}{})
		if !loaded {
			break
		}
		time.Sleep(lockCheckDelay)
		if time.Since(start) > lockTimeout {
			return nil, errLockTimeout
		}
	}
	return func() {
		s.nodesLocks.Delete(nodeLockKey)
		s.keysLocks.Delete(keyLockKey)
	}, nil
}
757942
func (c *ConfigLocal) KeyCache() KeyCache {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.kcache
}
711198
func (_m *DistributedLock) Lock(ctx context.Context) error {
	ret := _m.Called(ctx)

	var r0 error
	if rf, ok := ret.Get(0).(func(context.Context) error); ok {
		r0 = rf(ctx)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
601274
func (t *TSMIndexIterator) Key() []byte {
	if t.key == nil {
		buf := t.b.access(t.offset, 0)
		t.key = readKey(buf)
		t.typ = buf[2+len(t.key)]
	}
	return t.key
}