Unlocks an abandoned mutex
979352
protected void unlockAbandonedLock(final String mutexName) {
        this.executeIgnoreRollback(
                new TransactionCallbackWithoutResult() {
                    @Override
                    protected void doInTransactionWithoutResult(TransactionStatus status) {
                        final EntityManager entityManager = getEntityManager();
                        final ClusterMutex clusterMutex = getClusterMutex(mutexName);

                        if (!isLockAbandoned(clusterMutex)) {
                            // No longer abandoned
                            return;
                        }

                        logger.warn("Unlocking abandoned " + clusterMutex);
                        clusterMutex.unlock();
                        entityManager.persist(clusterMutex);
                        try {
                            entityManager.flush();
                        } catch (OptimisticLockException e) {
                            logger.trace(
                                    "Abandoned mutex {} was cleared by another thread or server",
                                    mutexName);
                        }
                    }
                });
    }
481003
protected function acquireMutex()
    {
        $this->mutex = Instance::ensure($this->mutex, Mutex::className());
        return $this->mutex->acquire($this->composeMutexName());
    }
544687
def release
      @refresh_mutex.synchronize {
        @unlock = true

        delete

        @refresh_signal.signal
      }


      @refresh_thread.join if @refresh_thread
      @event_manager.create_event(
        {
          user: Config.current_job.username,
          action: 'release',
          object_type: 'lock',
          object_name: @name,
          task: @task_id,
          deployment: @deployment_name,
        }
      )
    end
1267864
def unlock(password)
      cmd = Xcode::Shell::Command.new "security"
      cmd << "unlock-keychain"
      cmd << "-p #{password}"
      cmd << "\"#{@path}\""
      cmd.execute
    end
1249513
def _unlock(self):
        """"""
        if self.locked:
            try:
                self.device.cu.unlock()
                self.locked = False
            except JnrpUnlockError as jue:
                raise UnlockError(jue.messsage)
1313782
private void unlockCompletely(ReentrantLock lockToUnlock){
        int counter = lockToUnlock.getHoldCount();

        for(int i = 0; i<counter; i++){
            lockToUnlock.unlock();
        }
    }
92178
public void unlock()
  {
      if (tc.isEntryEnabled()) Tr.entry(tc, "unlock");

      if (_handle2 != null)
      {
        releaseLock(_handle2);
      }
      if (_handle1 != null)
      {
        releaseLock(_handle1);
      }

      _handle2=null;
      _handle1=null;

      if (tc.isEntryEnabled()) Tr.exit(tc, "unlock");
  }
1208760
@Beta
    public static <T> Predicate<T> sp(final Object mutex, final Predicate<T> predicate) {
        N.checkArgNotNull(mutex, "mutex");
        N.checkArgNotNull(predicate, "predicate");

        return new Predicate<T>() {
            @Override
            public boolean test(T t) {
                synchronized (mutex) {
                    return predicate.test(t);
                }
            }
        };
    }
1267485
def flush
      mutex.synchronize do
        if thread && thread.alive?
          queue.push(marker)
          marker.wait(mutex)
        end
      end
    end
1266787
public final void unlockFromUpgrade(L locker) {
        int upgradeCount = mUpgradeCount - 1;
        if (upgradeCount < 0) {
            throw new IllegalMonitorStateException("Too many upgrade locks released");
        }
        if (upgradeCount == 0 && mWriteCount > 0) {
            // Don't release last upgrade lock and switch write lock to
            // automatic upgrade mode.
            clearUpgradeLock(mState);
            return;
        }
        mUpgradeCount = upgradeCount;
        if (upgradeCount > 0) {
            return;
        }

        mOwner = null;

        // keep looping on CAS failure if reader mucked with state
        while (!clearUpgradeLock(mState)) {}

        Node h = mUHead;
        if (h != null && h.mWaitStatus != 0) {
            unparkUpgradeSuccessor(h);
        }
    }
26149
def clean_locks(root=None):
    '''
    
    '''
    LCK = "removed"
    out = {LCK: 0}
    locks = os.path.join(root, os.path.relpath(LOCKS, os.path.sep)) if root else LOCKS
    if not os.path.exists(locks):
        return out

    for node in __zypper__(root=root).xml.call('cl').getElementsByTagName("message"):
        text = node.childNodes[0].nodeValue.lower()
        if text.startswith(LCK):
            out[LCK] = text.split(" ")[1]
            break

    return out
1006522
public synchronized void lockExclusive()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "lockExclusive", this);

        boolean interrupted = false;

        // If another thread is attempting to lock exclusive,
        // wait for it to finish first.
        while (!tryLockExclusive())
        {
            try
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting to get exclusive lock");
                wait(1000);
            }
            catch (InterruptedException e)
            {
                // No FFDC code needed
                interrupted = true;
            }
        }

            // Wait for existing locks to be released
        while (iLockCount > 0)
        {
            try
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting for lock count to reach 0 " + iLockCount);
                wait(1000);
            }
            catch (InterruptedException e)
            {
                // No FFDC code needed
                interrupted = true;
            }
        }

        if (interrupted)
        {
            Thread.currentThread().interrupt();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "lockExclusive");
    }
1117472
def release(self):
        """"""
        if not self.acquired:
            raise threading.ThreadError("Unable to release an unacquired"
                                        " lock")
        try:
            self.unlock()
        except IOError:
            self.logger.exception("Could not unlock the acquired lock opened"
                                  " on `%s`", self.path)
        else:
            self.acquired = False
            try:
                self._do_close()
            except IOError:
                self.logger.exception("Could not close the file handle"
                                      " opened on `%s`", self.path)
            else:
                self.logger.log(_utils.BLATHER,
                                "Unlocked and closed file lock open on"
                                " `%s`", self.path)
37399
def wait(mutex, timeout = nil)
      start_time = Garcon.monotonic_time
      @condition.wait(mutex, timeout)

      if timeout.nil?
        Result.new(nil)
      else
        Result.new(start_time + timeout - Garcon.monotonic_time)
      end
    end
204017
def run(self):
        """"""

        log.info("Waiting for lock, currently held by %s", self.lock.who())
        if self.lock.acquire():
            log.info("Lock '%s' acquired", self.lockname)
            # We got the lock, so we make sure the process is running and keep refreshing the lock - if we ever stop for any reason, for example because our host died, the lock will soon expire.
            while True:
                if self.process is None:  # Process not spawned yet
                    self.process = self.spawn(self.command)
                    log.info("Spawned PID %d", self.process.pid)
                child_status = self.process.poll()
                if child_status is not None:
                    # Oops, process died on us.
                    log.error("Child died with exit code %d", child_status)
                    sys.exit(1)
                # Refresh lock and sleep
                if not self.lock.refresh():
                    who = self.lock.who()
                    if who is None:
                        if self.lock.acquire(block=False):
                            log.warning("Lock refresh failed, but successfully re-acquired unclaimed lock")
                        else:
                            log.error("Lock refresh and subsequent re-acquire failed, giving up (Lock now held by %s)", self.lock.who())
                            self.cleanup()
                            sys.exit(os.EX_UNAVAILABLE)
                    else:
                        log.error("Lock refresh failed, %s stole it - bailing out", self.lock.who())
                        self.cleanup()
                        sys.exit(os.EX_UNAVAILABLE)
                time.sleep(self.sleep)
541491
public void unlockCurrent() 
  throws SISessionUnavailableException, SISessionDroppedException,
         SIResourceException, SIConnectionLostException, 
         SIIncorrectCallException,
         SIErrorException, SIMPMessageNotLockedException
  {
    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.entry(CoreSPILockedMessageEnumeration.tc, "unlockCurrent", 
        new Object[] { new Integer(hashCode()), this});
    
    unlockCurrent(false);

    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.exit(CoreSPILockedMessageEnumeration.tc, "unlockCurrent", this);
  }
595077
async def release(self):
        ""
        expected_token = self.local.token
        if expected_token is None:
            raise LockError("Cannot release an unlocked lock")
        self.local.token = None
        await self.do_release(expected_token)