Java 8 ReentrantReadWriteLock - 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 class.

This code example shows how to use the following methods:readLock, writeLock
 */ 
public abstract class BaseIndexStore implements IndexStore { 
 
    protected static final float LOAD_FACTOR = 0.75F;
 
    protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    protected ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
    protected ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
 
    protected void takeWriteLock() { 
        writeLock.lock();
    } 
 
    protected void releaseWriteLock() { 
        writeLock.unlock();
    } 
 
    protected void takeReadLock() { 
        readLock.lock();
    } 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
        if (maxSize < 1) {
            throw new IllegalArgumentException("maxSize " + maxSize
                    + " must be at least 1"); 
        } 
        map = new BoundedLinkedHashMap<String, T>(maxSize);
        ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
        rlock = lock.readLock();
        wlock = lock.writeLock();
    } 
 
    /** 
     * Adds an entry to the cache, evicting the ealiest entry if necessary. 
     */ 
    public T add(String key, T value) {
        wlock.lock();
        try { 
            return map.put(key, value);
        } finally { 
            wlock.unlock();
        } 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 *  
 * @lucene.experimental 
 */ 
public class Cl2oTaxonomyWriterCache implements TaxonomyWriterCache {   
 
  private final ReadWriteLock lock = new ReentrantReadWriteLock();
  private final int initialCapcity, numHashArrays;
  private final float loadFactor;
   
  private volatile CompactLabelToOrdinal cache;
 
  /** Sole constructor. */ 
  public Cl2oTaxonomyWriterCache(int initialCapcity, float loadFactor, int numHashArrays) {
    this.cache = new CompactLabelToOrdinal(initialCapcity, loadFactor, numHashArrays);
    this.initialCapcity = initialCapcity;
    this.numHashArrays = numHashArrays;
    this.loadFactor = loadFactor;
  } 
 
  @Override 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
 * @author Michael C. Han 
 */ 
public class LiferayLoggerFactory implements ILoggerFactory { 
 
	public LiferayLoggerFactory() { 
		ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
 
		_readLock = readWriteLock.readLock();
		_writeLock = readWriteLock.writeLock();
	} 
 
	@Override 
	public Logger getLogger(String name) {
		Logger logger = null; 
 
		_readLock.lock();
 
		try { 
			logger = _loggers.get(name);
		} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
public class SRFReentrantReadWriteLock { 
	private final Lock readLock;
	private final Lock writeLock;
 
	public SRFReentrantReadWriteLock(AtomicInteger lockCounter) {
		ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
		this.readLock = new SRFBlockLock(lock.readLock(), lockCounter);
		this.writeLock = new SRFBlockLock(lock.writeLock(), lockCounter);
	} 
 
	public Lock readLock() {
		return readLock;
	} 
 
	public Lock writeLock() {
		return writeLock;
	} 
} 
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 * Keeps track of all connections and allows them to be closed later. 
 */ 
public class ConnectionTrackingHandler extends SimpleChannelHandler { 
 
    private final ChannelGroup openConnections = new DefaultChannelGroup();
    private final ReadWriteLock closingLock = new ReentrantReadWriteLock();
    private volatile boolean closed = false;
 
    @Override 
    public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
        // This lock is to deal with the race condition when closeAllConnections() is called, 
        // but the server is still accepting connections. Any new channels will be automatically closed. 
        closingLock.readLock().lock();
        try { 
            if (closed) {
                e.getChannel().close();
            } else { 
                openConnections.add(e.getChannel());
            } 
        } finally { 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
public class SynchronizedIndexAccessorImpl implements IndexAccessor { 
 
	public SynchronizedIndexAccessorImpl(IndexAccessor indexAccessor) {
		_indexAccessor = indexAccessor;
 
		ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
 
		_readLock = readWriteLock.readLock();
		_writeLock = readWriteLock.writeLock();
	} 
 
	@Override 
	public IndexSearcher acquireIndexSearcher() throws IOException {
		_readLock.lock();
 
		try { 
			return _indexAccessor.acquireIndexSearcher();
		} 
		finally { 
			_readLock.unlock();
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
        public final Lock readLock;
 
        public final Lock writeLock;
 
        { 
            final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(true);
            readLock = readWriteLock.readLock();
            writeLock = readWriteLock.writeLock();
        } 
    } 
 
    /** 
     * The active storage providers. 
     */ 
    private final Map<String, StorageProvider> mProviders = new LinkedHashMap<String, StorageProvider>();
 
    /** 
     * Locking data for the active storage providers. 
     */ 
    private final Map<StorageProvider, SynchronizationAid> mProviderLocks = new IdentityHashMap<StorageProvider, SynchronizationAid>();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
    private final Map<Method, String> attributeNameCache = new HashMap<Method, String>();
 
    private final Map<Method, Boolean> versionAttributeGetterCache = new HashMap<Method, Boolean>();
    private final Map<Method, Boolean> autoGeneratedKeyGetterCache = new HashMap<Method, Boolean>();
 
    private final ReentrantReadWriteLock readWriteLockAttrName = new ReentrantReadWriteLock();
    private final ReadLock readLockAttrName = readWriteLockAttrName.readLock();
    private final WriteLock writeLockAttrName = readWriteLockAttrName.writeLock();
 
    /** 
     * Returns the set of getter methods which are relevant when marshalling or 
     * unmarshalling an object. 
     */ 
    Collection<Method> getRelevantGetters(Class<?> clazz) {
        synchronized (getterCache) {
            if ( !getterCache.containsKey(clazz) ) {
                List<Method> relevantGetters = findRelevantGetters(clazz);
                getterCache.put(clazz, relevantGetters);
            } 
            return getterCache.get(clazz);
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readLock, writeLock
 
	public static final String DEBUG_OPTION = BeansCorePlugin.PLUGIN_ID + "/model/metadata/debug";
 
	public static final boolean DEBUG = SpringCore.isDebug(DEBUG_OPTION);
 
	private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
 
	private final Lock r = rwl.readLock();
 
	private final Lock w = rwl.writeLock();
 
	private Map<String, BeanMetadataHolder> beanMetadata = new ConcurrentHashMap<String, BeanMetadataHolder>();
 
	private Map<String, BeanPropertyDataHolder> beanPropertyData = new ConcurrentHashMap<String, BeanPropertyDataHolder>();
 
	public Set<IBeanMetadata> getBeanMetadata(IBean bean) {
		try { 
			r.lock();
			if (beanMetadata.containsKey(bean.getElementID())) {
				return beanMetadata.get(bean.getElementID()).getBeanMetaData();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 ReentrantReadWriteLock Questions & Answers:

See Code Examples for Java 8 ReentrantReadWriteLock Methods: