/** * 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]); } }
/** * 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]); } }
l.unlockWrite(_stamp);
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; }
/** * 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; }