Assumes you hold the lock
763310
def _print_if_needed(self):
        """"""
        if self._in_txn or self.print_frequency is None:
            return
        elif self.last_export is not None and \
             self.last_export + self.print_frequency > time.time():
            return

        self.export()
752824
public void lock() {
        Thread t = Thread.currentThread();
        if (t == owner.get()) { // if re-enter, increment the count.
            count++;
            return;
        }
        while (owner.compareAndSet(null, t)) {
        } //spin
    }
572789
def try_lock
      locked = false
      Thread.exclusive do
        clean
        unless(locked?(false))
          do_lock
          locked = true
        else
          locked = owner?(Thread.current)
        end
      end
      locked
    end
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;
    }
1313782
private void unlockCompletely(ReentrantLock lockToUnlock){
        int counter = lockToUnlock.getHoldCount();

        for(int i = 0; i<counter; i++){
            lockToUnlock.unlock();
        }
    }
763023
function(){
      if (this.locked)
      {
        this.locked--;

        if (!this.locked)
        {
          var lockedValue = this.lockedValue_;

          this.lockedValue_ = null;

          if (this.value !== lockedValue)
            this.emit_change(lockedValue);
        }
      }
    }
951480
private static Object getLockObject(Object key) {
    int hc = key.hashCode();
    return KEY_LOCKS[hc & KEY_LOCKS_MASK];
  }
255559
def with_lock(lock, func, *args, **kwargs):
    
    d = lock.acquire()

    def release_lock(result):
        deferred = lock.release()
        return deferred.addCallback(lambda x: result)

    def lock_acquired(lock):
        return defer.maybeDeferred(func, *args, **kwargs).addBoth(release_lock)

    d.addCallback(lock_acquired)
    return d
720386
def get_locked_variable(self, key, access_key):
        
        return self.get_variable(key, per_reference=False, access_key=access_key)
468933
def __initLock(self):
        """"""
        self._isLocked = False
        self._timer = 0
        self._operation = False
821764
private void takeCloseLock()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "takeCloseLock");

      while (true)
      {
         try
         {
            closeLock.readLock().lockInterruptibly();
            break;
         }
         catch (InterruptedException e)
         {
            // No FFDC code needed.
         }
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "takeCloseLock");
   }
692445
@GuardedBy("lock")
    protected void compact() {
        if(read_pos == 0)
            return;
        if(size() == 0) {
            read_pos=write_pos=0;
            return;
        }
        int length=write_pos - read_pos;
        System.arraycopy(buf, read_pos, buf, 0, length);
        write_pos-=read_pos;
        read_pos=0;
        not_full.signalAll();
    }
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;

    }
1027682
def thread_lock(lock):
    """"""
    if hasattr(lock, '_lock'):
        return lock._lock
    elif hasattr(lock, 'acquire'):
        return lock
    else:
        raise TypeError('expecting Lock/RLock')
127305
function Lock(target, name, descriptor) {
    let fn = descriptor.value;
    let $$LockIsDoing = false;

    let reset = ()=>$$LockIsDoing=false;
    descriptor.value = function(...args) {
        if ($$LockIsDoing) return;
        $$LockIsDoing = true;

        let ret = fn.apply(this, args);

        if (ret && ret.then) {
            // is promise
            return ret.then((succ)=>{
                reset();
                return Promise.resolve(succ);
            }, (fail)=>{
                reset();
                return Promise.reject(fail);
            });
        } else {
            reset();
            return ret;
        }
    };

    return descriptor;
}
166659
def lock(self, name, **kwargs):
        
        return self.pubsub.store.client().lock(self.prefixed(name), **kwargs)
47451
def _lock(self):
        """"""
        if not self.locked:
            self.device.cu.lock()
            self.locked = True