Java 8 ReentrantReadWriteLock.ReadLock - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ReentrantReadWriteLock.ReadLock class.

This code example shows how to use the following methods:lock, unlock
        } 
    } 
 
    /** Returns the value of the given key; or null of no such entry exists. */ 
    public T get(String key) {
        rlock.lock();
        try { 
            return map.get(key);
        } finally { 
            rlock.unlock();
        } 
    } 
 
    /** 
     * Returns the current size of the cache. 
     */ 
    public int size() { 
        rlock.lock();
        try { 
            return map.size();
6
CodeRank
This code example shows how to use the following methods:lock, unlock
    /** 
     * Returns the attribute name corresponding to the given getter method. 
     */ 
    String getAttributeName(Method getter) {
        String attributeName;
        readLockAttrName.lock();
        try { 
            attributeName = attributeNameCache.get(getter);
        } finally { 
            readLockAttrName.unlock();
        } 
        if ( attributeName != null )
            return attributeName;
        DynamoDBHashKey hashKeyAnnotation = ReflectionUtils.getAnnotationFromGetterOrField(getter, DynamoDBHashKey.class);
        if ( hashKeyAnnotation != null ) {
            attributeName = hashKeyAnnotation.attributeName();
            if ( attributeName != null && attributeName.length() > 0 )
                return cacheAttributeName(getter, attributeName);
        } 
        DynamoDBIndexHashKey indexHashKey = ReflectionUtils.getAnnotationFromGetterOrField(getter, DynamoDBIndexHashKey.class);
6
CodeRank
This code example shows how to use the following methods:lock, unlock
        this.maxSize = maxSize;
    } 
 
    public String getName(QName qName)
    { 
        qNameToNameReadLock.lock();
        try 
        { 
            return qNameToNameCache.get(qName);
        } 
        finally 
        { 
            qNameToNameReadLock.unlock();
        } 
    } 
     
    public void putQNameToName(QName qName, String name)
    { 
        qNameToNameWriteLock.lock();
        try 
6
CodeRank
This code example shows how to use the following methods:lock, unlock
			writeLock.unlock();
		} 
	} 
 
	public <T> T[] toArray(T[] a) {
		readLock.lock();
		try { 
			return elements.toArray(a);
		} 
		finally { 
			readLock.unlock();
		} 
	} 
 
	@Override 
	public String toString() {
		readLock.lock();
		try { 
			return StringUtils.collectionToCommaDelimitedString(elements);
		} 
6
CodeRank
This code example shows how to use the following methods:lock, unlock
		return false; 
	} 
 
	private void tryCloseReader() { 
		if(this.reader != null) {
			this.readSessionLock.lock();
			try { 
				try { 
					this.reader.close();
				} catch (IOException ioe) {
					logger.e("Unable to close reader for session file", ioe);
				} finally { 
					this.reader = null;
				} 
			} finally { 
				this.readSessionLock.unlock();
			} 
		} 
	} 
 

5
CodeRank
This code example shows how to use the following methods:lock, unlock
     * {@inheritDoc} 
     */ 
    @Override 
    public boolean getAllowWrite() 
    { 
        vetoReadLock.lock();
        try 
        { 
            return writeVeto.isEmpty() && this.sysAdminParams.getAllowWrite();
        } 
        finally 
        { 
            vetoReadLock.unlock();
        } 
    } 
     
    /** 
     * Set the read-only mode for all generated transactions. 
     * <p> 
     * Intended for use by spring configuration only.   Alfresco code should call the method which  
5
CodeRank
This code example shows how to use the following methods:lock, unlock
	} 
 
	public Value get(Key k) {
		Value result = null;
		try { 
			readLock.lock();
			result = content.get(k);
			if (result != null || content.containsKey(k))
				return result;
		} finally { 
			readLock.unlock();
		} 
		result = f.apply(k);
		try { 
			writeLock.lock();
			// f.apply(k) should produce equal results for equal keys 
			// it is save to put the new result without checking for a 
			// value that has been set meanwhile 
			content.put(k, result);
		} finally { 
5
CodeRank
This code example shows how to use the following methods:lock, unlock
  private ReentrantReadWriteLock _lock = new ReentrantReadWriteLock();
   
  public <T> T runReadOperation(Callable<T> call) throws ExceptionReadLock rl = _lock.readLock();
    rl.lock();
    try { 
      return call.call();
    } finally { 
      rl.unlock();
    } 
  } 
   
  public void runReadOperation(Runnable r)
  { 
    ReadLock rl = _lock.readLock();
    rl.lock();
    try { 
      r.run();
    } finally { 
5
CodeRank
This code example shows how to use the following methods:lock, unlock
        this.maxSize = maxSize;
    } 
 
    public String getName(QName qName)
    { 
        qNameToNameReadLock.lock();
        try 
        { 
            return qNameToNameCache.get(qName);
        } 
        finally 
        { 
            qNameToNameReadLock.unlock();
        } 
    } 
     
    public void putQNameToName(QName qName, String name)
    { 
        qNameToNameWriteLock.lock();
        try 
5
CodeRank
This code example shows how to use the following methods:lock, unlock
     * <em>currently</em> contain values. 
     *  
     * @return the Set of non-empty field keys 
     */ 
    protected Set<K> describe() {
        read.lock();
        try { 
            return Collections.unmodifiableSet(present.keySet()); /* Authorized */
        } 
        finally { 
            read.unlock();
        } 
    } 
 
    /** 
     * Return the Set of {@code keys} that mapped to fields which contained 
     * values at {@code timestamp}. 
     *  
     * @param timestamp 
     * @return the Set of non-empty field keys 
4
CodeRank
See Code Examples for Java 8 ReentrantReadWriteLock.ReadLock Methods: