项目:bts
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
void expireEntries() {
drainRecencyQueue();
if (expirationQueue.isEmpty()) {
// There's no point in calling nanoTime() if we have no entries to
// expire.
return;
}
long Now = map.ticker.read();
ReferenceEntry<K,V> e;
while ((e = expirationQueue.peek()) != null && map.isExpired(e,Now)) {
if (!removeEntry(e,e.getHash(),RemovalCause.EXPIRED)) {
throw new AssertionError();
}
}
}
项目:bts
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
boolean removeEntry(ReferenceEntry<K,V> entry,int hash,RemovalCause cause) {
int newCount = this.count - 1;
atomicreferenceArray<ReferenceEntry<K,V>> table = this.table;
int index = hash & (table.length() - 1);
ReferenceEntry<K,V> first = table.get(index);
for (ReferenceEntry<K,V> e = first; e != null; e = e.getNext()) {
if (e == entry) {
++modCount;
enqueueNotification(e.getKey(),hash,e.getValueReference().get(),cause);
ReferenceEntry<K,V> newFirst = removeFromChain(first,e);
newCount = this.count - 1;
table.set(index,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:j2objc
文件:MapMakerInternalMap.java
项目:j2objc
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:guava-libraries
文件:MapMakerInternalMap.java
项目:guava-libraries
文件:MapMakerInternalMap.java
@GuardedBy("this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:guava-libraries
文件:MapMakerInternalMapTest.java
public void testRemovalListener_collected() {
QueuingRemovalListener<Object,Object> listener =
new QueuingRemovalListener<Object,Object>();
MapMakerInternalMap<Object,Object> map = makeMap(createMapMaker()
.concurrencyLevel(1)
.softValues()
.removalListener(listener));
Segment<Object,Object> segment = map.segments[0];
assertTrue(listener.isEmpty());
Object one = new Object();
Object two = new Object();
Object three = new Object();
map.put(one,two);
map.put(two,three);
assertTrue(listener.isEmpty());
int hash = map.hash(one);
ReferenceEntry<Object,Object> entry = segment.getEntry(one,hash);
map.reclaimValue(entry.getValueReference());
assertNotified(listener,one,two,RemovalCause.COLLECTED);
assertTrue(listener.isEmpty());
}
项目:guava-libraries
文件:MapMakerInternalMapTest.java
public void testRemovalListener_size() {
QueuingRemovalListener<Object,Object> map = makeMap(createMapMaker()
.concurrencyLevel(1)
.maximumSize(2)
.removalListener(listener));
assertTrue(listener.isEmpty());
Object one = new Object();
Object two = new Object();
Object three = new Object();
Object four = new Object();
map.put(one,three);
assertTrue(listener.isEmpty());
map.put(three,four);
assertNotified(listener,RemovalCause.SIZE);
assertTrue(listener.isEmpty());
}
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
@GuardedBy("this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:My-Wallet-Android
文件:MapMakerInternalMap.java
项目:My-Wallet-Android
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:cnGuava
文件:MapMakerInternalMap.java
项目:cnGuava
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:org.openntf.domino
文件:MapMakerInternalMap.java
项目:org.openntf.domino
文件:MapMakerInternalMap.java
@GuardedBy("Segment.this")
boolean removeEntry(ReferenceEntry<K,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
}
项目:bts
文件:MapMakerInternalMap.java
/**
* Performs eviction if the segment is full. This should only be called prior to adding a new
* entry and increasing {@code count}.
*
* @return {@code true} if eviction occurred
*/
@GuardedBy("Segment.this")
boolean evictEntries() {
if (map.evictsBySize() && count >= maxSegmentSize) {
drainRecencyQueue();
ReferenceEntry<K,V> e = evictionQueue.remove();
if (!removeEntry(e,RemovalCause.SIZE)) {
throw new AssertionError();
}
return true;
}
return false;
}
项目:bts
文件:MapMakerInternalMap.java
void clear() {
if (count != 0) {
lock();
try {
atomicreferenceArray<ReferenceEntry<K,V>> table = this.table;
if (map.removalNotificationQueue != disCARDING_QUEUE) {
for (int i = 0; i < table.length(); ++i) {
for (ReferenceEntry<K,V> e = table.get(i); e != null; e = e.getNext()) {
// Computing references aren't actually in the map yet.
if (!e.getValueReference().isComputingReference()) {
enqueueNotification(e,RemovalCause.EXPLICIT);
}
}
}
}
for (int i = 0; i < table.length(); ++i) {
table.set(i,null);
}
clearReferenceQueues();
evictionQueue.clear();
expirationQueue.clear();
readCount.set(0);
++modCount;
count = 0; // write-volatile
} finally {
unlock();
postWriteCleanup();
}
}
}
项目:bts
文件:MapMakerInternalMap.java
/**
* Removes an entry whose key has been garbage collected.
*/
boolean reclaimKey(ReferenceEntry<K,int hash) {
lock();
try {
int newCount = count - 1;
atomicreferenceArray<ReferenceEntry<K,V>> table = this.table;
int index = hash & (table.length() - 1);
ReferenceEntry<K,V> first = table.get(index);
for (ReferenceEntry<K,V> e = first; e != null; e = e.getNext()) {
if (e == entry) {
++modCount;
enqueueNotification(
e.getKey(),RemovalCause.COLLECTED);
ReferenceEntry<K,e);
newCount = this.count - 1;
table.set(index,newFirst);
this.count = newCount; // write-volatile
return true;
}
}
return false;
} finally {
unlock();
postWriteCleanup();
}
}
项目:bts
文件:MapMakerInternalMap.java
/**
* Removes an entry whose value has been garbage collected.
*/
boolean reclaimValue(K key,ValueReference<K,V> valueReference) {
lock();
try {
int newCount = this.count - 1;
atomicreferenceArray<ReferenceEntry<K,V> e = first; e != null; e = e.getNext()) {
K entryKey = e.getKey();
if (e.getHash() == hash && entryKey != null
&& map.keyEquivalence.equivalent(key,entryKey)) {
ValueReference<K,V> v = e.getValueReference();
if (v == valueReference) {
++modCount;
enqueueNotification(key,valueReference.get(),RemovalCause.COLLECTED);
ReferenceEntry<K,e);
newCount = this.count - 1;
table.set(index,newFirst);
this.count = newCount; // write-volatile
return true;
}
return false;
}
}
return false;
} finally {
unlock();
if (!isHeldByCurrentThread()) { // don't cleanup inside of put
postWriteCleanup();
}
}
}
V compute(K key,ReferenceEntry<K,V> e,ComputingValueReference<K,V> computingValueReference)
throws ExecutionException {
V value = null;
long start = System.nanoTime();
long end = 0;
try {
// Synchronizes on the entry to allow failing fast when a recursive computation is
// detected. This is not fool-proof since the entry may be copied when the segment
// is written to.
synchronized (e) {
value = computingValueReference.compute(key,hash);
end = System.nanoTime();
}
if (value != null) {
// putIfAbsent
V oldValue = put(key,value,true);
if (oldValue != null) {
// the computed value was already clobbered
enqueueNotification(key,RemovalCause.REPLACED);
}
}
return value;
} finally {
if (end == 0) {
end = System.nanoTime();
}
if (value == null) {
clearValue(key,computingValueReference);
}
}
}
项目:j2objc
文件:MapMakerInternalMap.java
/**
* Performs eviction if the segment is full. This should only be called prior to adding a new
* entry and increasing {@code count}.
*
* @return {@code true} if eviction occurred
*/
@GuardedBy("Segment.this")
boolean evictEntries() {
if (map.evictsBySize() && count >= maxSegmentSize) {
drainRecencyQueue();
ReferenceEntry<K,RemovalCause.SIZE)) {
throw new AssertionError();
}
return true;
}
return false;
}
项目:j2objc
文件:MapMakerInternalMap.java
void clear() {
if (count != 0) {
lock();
try {
atomicreferenceArray<ReferenceEntry<K,null);
}
clearReferenceQueues();
evictionQueue.clear();
expirationQueue.clear();
readCount.set(0);
++modCount;
count = 0; // write-volatile
} finally {
unlock();
postWriteCleanup();
}
}
}
项目:j2objc
文件:MapMakerInternalMap.java
项目:j2objc
文件:MapMakerInternalMap.java
/**
* Removes an entry whose value has been garbage collected.
*/
boolean reclaimValue(K key,newFirst);
this.count = newCount; // write-volatile
return true;
}
return false;
}
}
return false;
} finally {
unlock();
if (!isHeldByCurrentThread()) { // don't cleanup inside of put
postWriteCleanup();
}
}
}
项目:guava-libraries
文件:MapMakerInternalMap.java
/**
* Performs eviction if the segment is full. This should only be called prior to adding a new
* entry and increasing {@code count}.
*
* @return {@code true} if eviction occurred
*/
@GuardedBy("this")
boolean evictEntries() {
if (map.evictsBySize() && count >= maxSegmentSize) {
drainRecencyQueue();
ReferenceEntry<K,RemovalCause.SIZE)) {
throw new AssertionError();
}
return true;
}
return false;
}
项目:guava-libraries
文件:MapMakerInternalMap.java
void clear() {
if (count != 0) {
lock();
try {
atomicreferenceArray<ReferenceEntry<K,null);
}
clearReferenceQueues();
evictionQueue.clear();
expirationQueue.clear();
readCount.set(0);
++modCount;
count = 0; // write-volatile
} finally {
unlock();
postWriteCleanup();
}
}
}
项目:guava-libraries
文件:MapMakerInternalMap.java
项目:guava-libraries
文件:MapMakerInternalMap.java
/**
* Removes an entry whose value has been garbage collected.
*/
boolean reclaimValue(K key,newFirst);
this.count = newCount; // write-volatile
return true;
}
return false;
}
}
return false;
} finally {
unlock();
if (!isHeldByCurrentThread()) { // don't cleanup inside of put
postWriteCleanup();
}
}
}
项目:guava-libraries
文件:MapMakerInternalMapTest.java
public void testRemovalListener_replaced() {
QueuingRemovalListener<Object,Object> map = makeMap(createMapMaker()
.removalListener(listener));
assertTrue(listener.isEmpty());
Object one = new Object();
Object two = new Object();
Object three = new Object();
Object four = new Object();
Object five = new Object();
Object six = new Object();
map.put(one,two);
map.put(one,three);
assertNotified(listener,RemovalCause.REPLACED);
Map<Object,Object> newMap = ImmutableMap.of(one,four);
map.putAll(newMap);
assertNotified(listener,three,RemovalCause.REPLACED);
map.replace(one,five);
assertNotified(listener,four,five,six);
assertNotified(listener,RemovalCause.REPLACED);
}
项目:guava-libraries
文件:MapMakerInternalMapTest.java
项目:guava-libraries
文件:MapMakerInternalMapTest.java
public void testRemoveEntry() {
MapMakerInternalMap<Object,Object> map = makeMap(createMapMaker()
.concurrencyLevel(1)
.initialCapacity(1)
.maximumSize(SMALL_MAX_SIZE)
.expireAfterWrite(99999,SECONDS)
.removalListener(new CountingRemovalListener<Object,Object>()));
Segment<Object,Object> segment = map.segments[0];
atomicreferenceArray<ReferenceEntry<Object,Object>> table = segment.table;
assertEquals(1,table.length());
Object key = new Object();
Object value = new Object();
int hash = map.hash(key);
DummyEntry<Object,Object> entry = createDummyEntry(key,null);
// remove absent
assertFalse(segment.removeEntry(entry,RemovalCause.COLLECTED));
// remove live
segment.recordWrite(entry);
table.set(0,entry);
segment.count = 1;
assertTrue(segment.removeEntry(entry,RemovalCause.COLLECTED));
assertNotificationEnqueued(map,key,value);
assertTrue(map.removalNotificationQueue.isEmpty());
assertFalse(segment.evictionQueue.contains(entry));
assertFalse(segment.expirationQueue.contains(entry));
assertEquals(0,segment.count);
assertNull(table.get(0));
}
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
/**
* Performs eviction if the segment is full. This should only be called prior to adding a new
* entry and increasing {@code count}.
*
* @return {@code true} if eviction occurred
*/
@GuardedBy("this")
boolean evictEntries() {
if (map.evictsBySize() && count >= maxSegmentSize) {
drainRecencyQueue();
ReferenceEntry<K,RemovalCause.SIZE)) {
throw new AssertionError();
}
return true;
}
return false;
}
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
void clear() {
if (count != 0) {
lock();
try {
atomicreferenceArray<ReferenceEntry<K,null);
}
clearReferenceQueues();
evictionQueue.clear();
expirationQueue.clear();
readCount.set(0);
++modCount;
count = 0; // write-volatile
} finally {
unlock();
postWriteCleanup();
}
}
}
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
项目:VectorAttackScanner
文件:MapMakerInternalMap.java
/**
* Removes an entry whose value has been garbage collected.
*/
boolean reclaimValue(K key,newFirst);
this.count = newCount; // write-volatile
return true;
}
return false;
}
}
return false;
} finally {
unlock();
if (!isHeldByCurrentThread()) { // don't cleanup inside of put
postWriteCleanup();
}
}
}
项目:My-Wallet-Android
文件:MapMakerInternalMap.java
/**
* Performs eviction if the segment is full. This should only be called prior to adding a new
* entry and increasing {@code count}.
*
* @return {@code true} if eviction occurred
*/
@GuardedBy("Segment.this")
boolean evictEntries() {
if (map.evictsBySize() && count >= maxSegmentSize) {
drainRecencyQueue();
ReferenceEntry<K,RemovalCause.SIZE)) {
throw new AssertionError();
}
return true;
}
return false;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。