List of usage examples for java.util.concurrent.locks ReentrantReadWriteLock readLock
public ReentrantReadWriteLock.ReadLock readLock()
From source file:org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities.java
public QueueCapacities(boolean isRoot) { ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); readLock = lock.readLock(); writeLock = lock.writeLock();//from w ww. j a v a2 s. com capacitiesMap = new HashMap<String, Capacities>(); this.isRoot = isRoot; }
From source file:org.bremersee.objectlock.ObjectReadWriteLockImpl.java
@Override public void lockReading(Object obj) { if (obj == null) { return;/* w w w .j av a2s.c o m*/ } ReentrantReadWriteLock l; synchronized (locks) { l = locks.get(obj); if (l == null) { l = borrowLock(); locks.put(obj, l); } } l.readLock().lock(); }
From source file:org.grouplens.samantha.modeler.space.SynchronizedVariableSpace.java
@Inject public SynchronizedVariableSpace() { ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); readLock = rwl.readLock(); writeLock = rwl.writeLock();//from www .jav a2 s . c o m }
From source file:com.locadz.HttpClientFactory.java
/** * Get a client instance. <br/>//from w w w.j av a 2s .c o m * Note: You should not assign the instance to a class variable. * @return a HttpClient instance. */ public static final HttpClient getInstance() { ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); try { readLock.lock(); HttpClient httpClient = instance.get(); if (httpClient == null) { readLock.unlock(); lock.writeLock().lock(); httpClient = instance.get(); if (httpClient == null) { httpClient = new DefaultHttpClient(); instance = new SoftReference<HttpClient>(httpClient); } readLock.lock(); lock.writeLock().unlock(); } return httpClient; } finally { readLock.unlock(); } }
From source file:org.alfresco.repo.content.AbstractRoutingContentStore.java
protected AbstractRoutingContentStore() { ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); storesCacheReadLock = lock.readLock(); storesCacheWriteLock = lock.writeLock(); }
From source file:org.apache.tez.dag.app.rm.node.AMNodeImpl.java
@SuppressWarnings("rawtypes") public AMNodeImpl(NodeId nodeId, int maxTaskFailuresPerNode, EventHandler eventHandler, boolean blacklistingEnabled, AppContext appContext) { ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); this.readLock = rwLock.readLock(); this.writeLock = rwLock.writeLock(); this.nodeId = nodeId; this.appContext = appContext; this.eventHandler = eventHandler; this.maxTaskFailuresPerNode = maxTaskFailuresPerNode; this.stateMachine = stateMachineFactory.make(this); // TODO Handle the case where a node is created due to the RM reporting it's // state as UNHEALTHY }
From source file:org.alfresco.repo.usage.RepoUsageComponentImpl.java
/** * Defaults/* w ww . j a v a 2 s .c om*/ */ public RepoUsageComponentImpl() { this.restrictions = new RepoUsage(null, null, null, LicenseMode.UNKNOWN, null, false); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); restrictionsReadLock = lock.readLock(); restrictionsWriteLock = lock.writeLock(); }
From source file:nl.basvanmarwijk.mylocations.viewcontroller.LocationItemDetailFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ReentrantReadWriteLock itemLock = new ReentrantReadWriteLock(); itemReadLock = itemLock.readLock(); itemWriteLock = itemLock.writeLock(); // verkrijg de locatie item uit de database final Bundle args = getArguments(); if (args.containsKey(ARG_ITEM_ID)) { final long id = args.getLong(ARG_ITEM_ID); DBManager dbManager = App.getDbManager(); Location item = dbManager.getLocationById(id); mItem = item;/*from w w w . ja va 2s . c om*/ } }
From source file:org.alfresco.repo.content.caching.CachingContentStore.java
@Override public boolean delete(String contentUrl) { if (contentUrl.startsWith(FileContentStore.SPOOF_PROTOCOL)) { // This is not a failure but the content can never actually be deleted return false; }/*from w ww. j a v a 2 s . c o m*/ ReentrantReadWriteLock readWriteLock = readWriteLock(contentUrl); ReadLock readLock = readWriteLock.readLock(); readLock.lock(); try { if (!cache.contains(contentUrl)) { // The item isn't in the cache, so simply delete from the backing store return backingStore.delete(contentUrl); } } finally { readLock.unlock(); } WriteLock writeLock = readWriteLock.writeLock(); writeLock.lock(); try { // Double check the content still exists in the cache if (cache.contains(contentUrl)) { // The item is in the cache, so remove. cache.remove(contentUrl); } // Whether the item was in the cache or not, it must still be deleted from the backing store. return backingStore.delete(contentUrl); } finally { writeLock.unlock(); } }
From source file:org.apache.openjpa.jdbc.kernel.PreparedQueryCacheImpl.java
public PreparedQueryCacheImpl() { _delegate = new CacheMap(); _uncachables = new CacheMap(); _exclusionPatterns = new ArrayList<Exclusion>(); ReentrantReadWriteLock _rwl = new ReentrantReadWriteLock(); _writeLock = _rwl.writeLock();/*w w w .j a va2 s . com*/ _readLock = _rwl.readLock(); }