/** * Release the all segment locks. * * @param _stamps array with the lock stamps. */ private void unlockAll(long[] _stamps) { OptimisticLock[] _locks = locks; int sn = _locks.length; for (int i = 0; i < sn; i++) { _locks[i].unlockWrite(_stamps[i]); } }
/** * Acquire all segment locks and return an array with the lock stamps. */ private long[] lockAll() { OptimisticLock[] _locks = locks; int sn = _locks.length; long[] _stamps = new long[locks.length]; for (int i = 0; i < sn; i++) { OptimisticLock l = _locks[i]; _stamps[i] = l.writeLock(); } return _stamps; }
int si = _hash & LOCK_MASK; OptimisticLock l = _locks[si]; long _stamp = l.tryOptimisticRead(); Entry<K,V>[] tab = entries; if (tab == null) { if (l.validate(_stamp)) { return null; _stamp = l.readLock(); try { tab = entries; l.unlockRead(_stamp);
int si = _hash & LOCK_MASK; OptimisticLock l = _locks[si]; long _stamp = l.writeLock(); try { Entry<K,V> f; Entry<K,V>[] tab = entries; l.unlockWrite(_stamp);
int si = _hash & LOCK_MASK; OptimisticLock l = _locks[si]; long _stamp = l.tryOptimisticRead(); Entry<K,V>[] tab = entries; if (tab == null) { if (l.validate(_stamp)) { return null; _stamp = l.readLock(); try { tab = entries; l.unlockRead(_stamp);
int si = _hash & LOCK_MASK; OptimisticLock l = _locks[si]; long _stamp = l.writeLock(); try { Entry f; Entry<K,V>[] tab = entries; l.unlockWrite(_stamp);
/** * Insert new entry in all structures (hash and eviction). The insert at the eviction * needs to be done under the same lock, to allow a check of the consistency. */ protected Entry<K, V> insertNewEntry(K key, int hc, int val) { Entry<K,V> e = new Entry<K,V>(extractIntKeyObj(key), val); Entry<K, V> e2; final OptimisticLock l = hash.getSegmentLock(hc); final long _stamp = l.writeLock(); boolean _needsEviction = false; try { e2 = hash.insertWithinLock(e, hc, val); if (e == e2) { _needsEviction = eviction.submitWithoutEviction(e); } } finally { l.unlockWrite(_stamp); } if (_needsEviction) { eviction.evictEventually(hc); } hash.checkExpand(hc); return e2; }
/** * Release the all segment locks. * * @param _stamps array with the lock stamps. */ private void unlockAll(long[] _stamps) { OptimisticLock[] _locks = locks; int sn = _locks.length; for (int i = 0; i < sn; i++) { _locks[i].unlockWrite(_stamps[i]); } }
/** * Acquire all segment locks and return an array with the lock stamps. */ private long[] lockAll() { OptimisticLock[] _locks = locks; int sn = _locks.length; long[] _stamps = new long[locks.length]; for (int i = 0; i < sn; i++) { OptimisticLock l = _locks[i]; _stamps[i] = l.writeLock(); } return _stamps; }
/** * Insert new entry in all structures (hash and eviction). The insert at the eviction * needs to be done under the same lock, to allow a check of the consistency. */ protected Entry<K, V> insertNewEntry(K key, int hc, int val) { Entry<K,V> e = new Entry<K,V>(extractIntKeyObj(key), val); Entry<K, V> e2; final OptimisticLock l = hash.getSegmentLock(hc); final long _stamp = l.writeLock(); boolean _needsEviction = false; try { e2 = hash.insertWithinLock(e, hc, val); if (e == e2) { _needsEviction = eviction.submitWithoutEviction(e); } } finally { l.unlockWrite(_stamp); } if (_needsEviction) { eviction.evictEventually(hc); } hash.checkExpand(hc); return e2; }
/** * Remove the entry from the hash and the replacement list. * There is a race condition to catch: The eviction may run * in a parallel thread and may have already selected this * entry. */ protected boolean removeEntry(Entry e) { int hc = extractModifiedHash(e); boolean _removed; OptimisticLock l = hash.getSegmentLock(hc); long _stamp = l.writeLock(); try { _removed = hash.removeWithinLock(e, hc); e.setGone(); if (_removed) { eviction.submitWithoutEviction(e); } } finally { l.unlockWrite(_stamp); } checkForHashCodeChange(e); timing.cancelExpiryTimer(e); return _removed; }
/** * Remove the entry from the hash and the replacement list. * There is a race condition to catch: The eviction may run * in a parallel thread and may have already selected this * entry. */ protected boolean removeEntry(Entry e) { int hc = extractModifiedHash(e); boolean _removed; OptimisticLock l = hash.getSegmentLock(hc); long _stamp = l.writeLock(); try { _removed = hash.removeWithinLock(e, hc); e.setGone(); if (_removed) { eviction.submitWithoutEviction(e); } } finally { l.unlockWrite(_stamp); } checkForHashCodeChange(e); timing.cancelExpiryTimer(e); return _removed; }