Locking: private method, lock will be held by the caller
342939
private void checkDynamic(int accessor) throws JMFSchemaViolationException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.entry(this, tc, "checkDynamic", new Object[] { Integer.valueOf(accessor) });

        JSField field = getFieldDef(accessor, false);

        if (field instanceof JSDynamic) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                JmfTr.exit(this, tc, "checkDynamic");
            return;
        }

        JMFSchemaViolationException e = new JMFSchemaViolationException("Field type at accessor " + accessor + " is not Dynamic");
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.exit(this, tc, "checkDynamic", e);
        throw e;
    }
711847
public void acquireLock (final NodeObject.Lock lock, final ResultListener<String> listener)
    {
        // wait until any pending resolution is complete
        queryLock(lock, new ChainedResultListener<String, String>(listener) {
            public void requestCompleted (String result) {
                if (result == null) {
                    if (_suboids.isEmpty()) {
                        lockAcquired(lock, 0L, listener);
                    } else {
                        _locks.put(lock, new LockHandler(lock, true, listener));
                    }
                } else {
                    listener.requestCompleted(result);
                }
            }
        });
    }
323406
def thread_safe(method):
    

    @functools.wraps(method)
    def _locker(self, *args, **kwargs):
        assert hasattr(self, 'lock'), \
            'thread_safe decorator applied to method {0}.{1}: missing required field {0}.lock'\
            .format(self.__class__.__name__, method.__name__)

        try:
            self.lock.acquire()
            return method(self, *args, **kwargs)
        finally:
            try:
                self.lock.release()
            except:
                sys.stderr.write('Exception on releasing lock at method {0}'.format(method.__name__))
                traceback.print_exc(file=sys.stderr)

    return _locker
787841
public void queryLock (NodeObject.Lock lock, ResultListener<String> listener)
    {
        // if it's being resolved, add the listener to the list
        LockHandler handler = _locks.get(lock);
        if (handler != null) {
            handler.listeners.add(listener);
            return;
        }

        // otherwise, return its present value
        listener.requestCompleted(queryLock(lock));
    }
997889
@Override
    public void lock(Object entity, LockModeType lockMode)
    {
        ivEm.lock(entity, lockMode);
    }
1335611
private final void contendedLock() {
            boolean waiting = false;
            for (int s;;) {
                if (((s = lockState) & ~WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
                        if (waiting)
                            waiter = null;
                        return;
                    }
                }
                else if ((s & WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
                        waiting = true;
                        waiter = Thread.currentThread();
                    }
                }
                else if (waiting)
                    LockSupport.park(this);
            }
        }
902207
private void handleWhereBlock(Method method) {
    Block block = method.getLastBlock();
    if (!(block instanceof WhereBlock)) return;

    new DeepBlockRewriter(this).visit(block);
    WhereBlockRewriter.rewrite((WhereBlock) block, this);
  }
1098699
def locked(self, lock):
        """"""
        _LOGGER.debug("Setting the lock: %s", lock)
        value = struct.pack('BB', PROP_LOCK, bool(lock))
        self._conn.make_request(PROP_WRITE_HANDLE, value)
686971
public synchronized void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade, List registeredObjects)
    {
        if(log.isDebugEnabled()) log.debug("Lock and register called for " + rtObject.getIdentity());
        // if current object was already locked, do nothing
        // avoid endless loops when circular object references are used
        if(!registeredObjects.contains(rtObject.getIdentity()))
        {
            if(cascade)
            {
                // if implicite locking is enabled, first add the current object to
                // list of registered objects to avoid endless loops on circular objects
                registeredObjects.add(rtObject.getIdentity());
                // lock and register 1:1 references first
                //
                // If implicit locking is used, we have materialize the main object
                // to lock the referenced objects too
                lockAndRegisterReferences(rtObject.getCld(), rtObject.getObjMaterialized(), lockMode, registeredObjects);
            }
            try
            {
                // perform the lock on the object
                // we don't need to lock new objects
                if(!rtObject.isNew())
                {
                    doSingleLock(rtObject.getCld(), rtObject.getObj(), rtObject.getIdentity(), lockMode);
                }
                // after we locked the object, register it to detect status and changes while tx
                doSingleRegister(rtObject, lockMode);
            }
            catch (Throwable t)
            {
                //log.error("Locking of obj " + rtObject.getIdentity() + " failed", t);
                // if registering of object fails release lock on object, because later we don't
                // get a change to do this.
                implementation.getLockManager().releaseLock(this, rtObject.getIdentity(), rtObject.getObj());
                if(t instanceof LockNotGrantedException)
                {
                    throw (LockNotGrantedException) t;
                }
                else
                {
                    log.error("Unexpected failure while locking", t);
                    throw new LockNotGrantedException("Locking failed for "
                            + rtObject.getIdentity()+ ", nested exception is: [" + t.getClass().getName()
                            + ": " + t.getMessage() + "]");
                }
            }
            if(cascade)
            {
                // perform locks and register 1:n and m:n references
                // If implicit locking is used, we have materialize the main object
                // to lock the referenced objects too
                lockAndRegisterCollections(rtObject.getCld(), rtObject.getObjMaterialized(), lockMode, registeredObjects);
            }
        }
    }
204171
public final Lock lock(Object key) {
        Lock lock = this.locks.get(key);
        lock.lock();
        return lock;
    }
1361054
def with_lock(lock):
  """"""
  def decorator(func):
    @functools.wraps(func)
    def _with_lock(*args, **kwargs):
      with lock:
        return func(*args, **kwargs)
    return _with_lock
  return decorator
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
643730
private <T> T doWithLock(LockCallback<T> callback) throws JobPersistenceException {
        return doWithLock(callback, null);
    }
245010
public synchronized boolean lock() throws KeeperException, InterruptedException {
        if (isClosed()) {
            return false;
        }
        ensurePathExists(dir);

        return (Boolean) retryOperation(zop);
    }
1133778
@Override
    public void lock(final Object maintainer) throws CouldNotPerformException {
        synchronized (maintainerLock) {
            if (this.maintainer != null) {
                throw new CouldNotPerformException("Could not lock remote because it is already locked by another instance!");
            }
            this.maintainer = maintainer;
        }
    }
706291
private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException
    {
        if (implicitLocking)
        {
            Iterator i = cld.getObjectReferenceDescriptors(true).iterator();
            while (i.hasNext())
            {
                ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next();
                Object refObj = rds.getPersistentField().get(sourceObject);
                if (refObj != null)
                {
                    boolean isProxy = ProxyHelper.isProxy(refObj);
                    RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this);
                    if (!registrationList.contains(rt.getIdentity()))
                    {
                        lockAndRegister(rt, lockMode, registeredObjects);
                    }
                }
            }
        }
    }
368831
def is_locked(lock):
    
    if hasattr(lock, 'locked'):
        return lock.locked()
    elif hasattr(lock, '_is_owned'):
        return lock._is_owned()
    else:
        raise TypeError('expecting Lock/RLock')