Called when a peer announces its intention to acquire a lock.
424517
protected void peerAcquiringLock (PeerNode peer, NodeObject.Lock lock)
    {
        // refuse to ratify if we believe someone else owns the lock
        String owner = queryLock(lock);
        if (owner != null) {
            log.warning("Refusing to ratify lock acquisition.", "lock", lock,
                "node", peer.getNodeName(), "owner", owner);
            return;
        }

        // check for an existing handler
        LockHandler handler = _locks.get(lock);
        if (handler == null) {
            createLockHandler(peer, lock, true);
            return;
        }

        // if the existing node has priority, we're done
        if (hasPriority(handler.getNodeName(), peer.getNodeName())) {
            return;
        }

        // the new node has priority, so cancel the existing handler and take over
        // its listeners
        ResultListenerList<String> olisteners = handler.listeners;
        handler.cancel();
        handler = createLockHandler(peer, lock, true);
        handler.listeners = olisteners;
    }
1323290
boolean detectDeadlock(Locker acquirer, Lock l, int mode) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "detectDeadlock", new Object[] { acquirer, l,
                                                         modeStrs[mode] });
        }

        boolean result = false;

        //----------------------------------------------------------------
        // Iterate through the holders of the given lock and determine if
        // any of them are waiting on a lock held by the requestor. If
        // any of them are then a deadlock exists.
        //----------------------------------------------------------------

        Enumeration holders = l.getHolders();
        while (holders.hasMoreElements()) {
            if (lockerWaitingOn((Locker) holders.nextElement(), acquirer)) {
                result = true;
                break;
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "detectDeadlock:" + result);
        }
        return result;

    }
767018
function forward (offer) {
  if (offer.answer) {
    peerTable[offer.srcId].socket
      .emit('we-handshake', offer)
    return
  }
  peerTable[offer.dstId].socket
    .emit('we-handshake', offer)
}
905422
def notify(self):
        
        if self.__method is not None:
            self.__method(self.__peer)
            return True
        return False
208892
protected void peerAddedLock (String nodeName, NodeObject.Lock lock)
    {
        // check for hijacking
        if (_nodeobj.locks.contains(lock)) {
            log.warning("Client hijacked lock owned by this node", "lock", lock, "node", nodeName);
            droppedLock(lock);
        }

        // notify the handler, if any
        LockHandler handler = _locks.get(lock);
        if (handler != null) {
            handler.peerAddedLock(nodeName);
        }
    }
217211
private void notifyConnected(Peer peer) {
		for(Listener listener : new HashSet<>(listeners)) {
			listener.onConnected(peer);
		}
	}
372165
def acquire(self,blocking=True,timeout=None,shared=False):
        """"""
        with self._lock:
            if shared:
                self._acquire_shared(blocking,timeout)
            else:
                self._acquire_exclusive(blocking,timeout)
            assert not (self.is_shared and self.is_exclusive)
67599
def release_lock(self):
    
    if not self._lock.acquired:
      return False
    else:
      self._lock.release()
      return True
644276
def release_lock(self, name):
        
        if self._remotelib:
            self._remotelib.run_keyword('release_lock',
                                        [name, self._my_id], {})
        else:
            _PabotLib.release_lock(self, name, self._my_id)
1286721
public function acquire()
    {
        $isAcquired = $this->lock->acquireLock($this->timeout->getValue());

        if (!$isAcquired) {
            throw new LockingException('Lock cannot be acquired.', 1438871269);
        }
    }
166469
private void onAcquire(final PooledConnection conn, String httpMethod, String uriStr, 
                           int attemptNum, CurrentPassport passport)
    {
        passport.setOnChannel(conn.getChannel());
        removeIdleStateHandler(conn);

        conn.setInUse();
        if (LOG.isDebugEnabled()) LOG.debug("PooledConnection acquired: " + conn.toString());
    }
315707
def _AcquireLock(self,
                   urn,
                   blocking=None,
                   blocking_lock_timeout=None,
                   lease_time=None,
                   blocking_sleep_interval=None):
    """"""
    if urn is None:
      raise ValueError("URN cannot be None")

    urn = rdfvalue.RDFURN(urn)

    try:
      return data_store.DB.LockRetryWrapper(
          urn,
          retrywrap_timeout=blocking_sleep_interval,
          retrywrap_max_timeout=blocking_lock_timeout,
          blocking=blocking,
          lease_time=lease_time)
    except data_store.DBSubjectLockError as e:
      raise LockError(e)
187323
function maybeReleaseLock() {
    var lock = self.client.lock;

    function done(err) {
      log.debug({client: self.client}, 'Closed client sync handler');
      self.client.lock = null;
      self.client = null;
      callback(err);
    }

    // No lock
    if(!lock) {
      return done();
    }
    // Lock reference, but it's already unlocked
    if(lock.unlocked) {
      return done();
    }
    // Holding lock, release it
    lock.release(function(err) {
      if(err) {
        log.error({err: err, client: self.client}, 'Error releasing sync lock');
        return done(err);
      }
      done();
    });
  }
1090210
def acquire(self, blocking=True, timeout=None):
        
        logger.debug("Getting %r ...", self._name)

        if self._held:
            raise AlreadyAcquired("Already acquired from this Lock instance.")

        if not blocking and timeout is not None:
            raise TimeoutNotUsable("Timeout cannot be used if blocking=False")

        timeout = timeout if timeout is None else int(timeout)
        if timeout is not None and timeout <= 0:
            raise InvalidTimeout("Timeout (%d) cannot be less than or equal to 0" % timeout)

        if timeout and self._expire and timeout > self._expire:
            raise TimeoutTooLarge("Timeout (%d) cannot be greater than expire (%d)" % (timeout, self._expire))

        busy = True
        blpop_timeout = timeout or self._expire or 0
        timed_out = False
        while busy:
            busy = not self._client.set(self._name, self._id, nx=True, ex=self._expire)
            if busy:
                if timed_out:
                    return False
                elif blocking:
                    timed_out = not self._client.blpop(self._signal, blpop_timeout) and timeout
                else:
                    logger.debug("Failed to get %r.", self._name)
                    return False

        logger.debug("Got lock for %r.", self._name)
        if self._lock_renewal_interval is not None:
            self._start_lock_renewer()
        return True
42737
public void performWithLock (final NodeObject.Lock lock, final LockedOperation operation)
    {
        acquireLock(lock, new ResultListener<String>() {
            public void requestCompleted (String nodeName) {
                if (getNodeObject().nodeName.equals(nodeName)) {
                    // lock acquired successfully - perform the operation, and release the lock.
                    try {
                        operation.run();
                    } finally {
                        releaseLock(lock, new ResultListener.NOOP<String>());
                    }
                } else {
                    // some other peer beat us to it
                    operation.fail(nodeName);
                    if (nodeName == null) {
                        log.warning("Lock acquired by null?", "lock", lock);
                    }
                }
            }
            public void requestFailed (Exception cause) {
                log.warning("Lock acquisition failed", "lock", lock, cause);
                operation.fail(null);
            }
        });
    }
565930
public function lock() {
        $this->primaryPrivateKey = null;
        $this->secret = null;
        $this->primarySeed = null;
        $this->locked = true;
    }
521575
def on_trap(object_id, &block)
      raise ArgumentError, "a block must be provided" unless block
      @lock.synchronize { @oid_handler[ObjectId.new(object_id)] = block }
    end