com.google.common.cache.LocalCache.usesValueReferences()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中com.google.common.cache.LocalCache.usesValueReferences()方法的一些代码示例,展示了LocalCache.usesValueReferences()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalCache.usesValueReferences()方法的具体详情如下:
包路径:com.google.common.cache.LocalCache
类名称:LocalCache
方法名:usesValueReferences

LocalCache.usesValueReferences介绍

暂无

代码示例

代码示例来源:origin: google/guava

/** Clears all entries from the key and value reference queues. */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: google/guava

/**
 * Drain the key and value reference queues, cleaning up internal entries containing garbage
 * collected keys or values.
 */
@GuardedBy("this")
void drainReferenceQueues() {
 if (map.usesKeyReferences()) {
  drainKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  drainValueReferenceQueue();
 }
}

代码示例来源:origin: wildfly/wildfly

/** Clears all entries from the key and value reference queues. */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: google/guava

Segment(
  LocalCache<K, V> map,
  int initialCapacity,
  long maxSegmentWeight,
  StatsCounter statsCounter) {
 this.map = map;
 this.maxSegmentWeight = maxSegmentWeight;
 this.statsCounter = checkNotNull(statsCounter);
 initTable(newEntryArray(initialCapacity));
 keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
 valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
 recencyQueue =
   map.usesAccessQueue()
     ? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 writeQueue =
   map.usesWriteQueue()
     ? new WriteQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 accessQueue =
   map.usesAccessQueue()
     ? new AccessQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}

代码示例来源:origin: wildfly/wildfly

/**
 * Drain the key and value reference queues, cleaning up internal entries containing garbage
 * collected keys or values.
 */
@GuardedBy("this")
void drainReferenceQueues() {
 if (map.usesKeyReferences()) {
  drainKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  drainValueReferenceQueue();
 }
}

代码示例来源:origin: google/j2objc

Segment(
  LocalCache<K, V> map,
  int initialCapacity,
  long maxSegmentWeight,
  StatsCounter statsCounter) {
 this.map = map;
 this.maxSegmentWeight = maxSegmentWeight;
 this.statsCounter = checkNotNull(statsCounter);
 initTable(newEntryArray(initialCapacity));
 keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
 valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
 recencyQueue =
   map.usesAccessQueue()
     ? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 writeQueue =
   map.usesWriteQueue()
     ? new WriteQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 accessQueue =
   map.usesAccessQueue()
     ? new AccessQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}

代码示例来源:origin: wildfly/wildfly

Segment(
  LocalCache<K, V> map,
  int initialCapacity,
  long maxSegmentWeight,
  StatsCounter statsCounter) {
 this.map = map;
 this.maxSegmentWeight = maxSegmentWeight;
 this.statsCounter = checkNotNull(statsCounter);
 initTable(newEntryArray(initialCapacity));
 keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
 valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
 recencyQueue =
   map.usesAccessQueue()
     ? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 writeQueue =
   map.usesWriteQueue()
     ? new WriteQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
 accessQueue =
   map.usesAccessQueue()
     ? new AccessQueue<K, V>()
     : LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}

代码示例来源:origin: google/guava

public void testDrainValueReferenceQueueOnWrite() {
 for (CacheBuilder<Object, Object> builder : allKeyValueStrengthMakers()) {
  LocalCache<Object, Object> map = makeLocalCache(builder.concurrencyLevel(1));
  if (map.usesValueReferences()) {
   Segment<Object, Object> segment = map.segments[0];
   Object keyOne = new Object();
   int hashOne = map.hash(keyOne);
   Object valueOne = new Object();
   Object keyTwo = new Object();
   Object valueTwo = new Object();
   map.put(keyOne, valueOne);
   ReferenceEntry<Object, Object> entry = segment.getEntry(keyOne, hashOne);
   ValueReference<Object, Object> valueReference = entry.getValueReference();
   @SuppressWarnings("unchecked")
   Reference<Object> reference = (Reference) valueReference;
   reference.enqueue();
   map.put(keyTwo, valueTwo);
   assertFalse(map.containsKey(keyOne));
   assertFalse(map.containsValue(valueOne));
   assertNull(map.get(keyOne));
   assertEquals(1, map.size());
   assertNull(segment.valueReferenceQueue.poll());
  }
 }
}

代码示例来源:origin: google/guava

public void testDrainValueReferenceQueueOnRead() {
 for (CacheBuilder<Object, Object> builder : allKeyValueStrengthMakers()) {
  LocalCache<Object, Object> map = makeLocalCache(builder.concurrencyLevel(1));
  if (map.usesValueReferences()) {
   Segment<Object, Object> segment = map.segments[0];
   Object keyOne = new Object();
   int hashOne = map.hash(keyOne);
   Object valueOne = new Object();
   Object keyTwo = new Object();
   map.put(keyOne, valueOne);
   ReferenceEntry<Object, Object> entry = segment.getEntry(keyOne, hashOne);
   ValueReference<Object, Object> valueReference = entry.getValueReference();
   @SuppressWarnings("unchecked")
   Reference<Object> reference = (Reference) valueReference;
   reference.enqueue();
   for (int i = 0; i < SMALL_MAX_SIZE; i++) {
    map.get(keyTwo);
   }
   assertFalse(map.containsKey(keyOne));
   assertFalse(map.containsValue(valueOne));
   assertNull(map.get(keyOne));
   assertEquals(0, map.size());
   assertNull(segment.valueReferenceQueue.poll());
  }
 }
}

代码示例来源:origin: com.diffplug.guava/guava-cache

/**
 * Drain the key and value reference queues, cleaning up internal entries containing garbage
 * collected keys or values.
 */
@GuardedBy("this")
void drainReferenceQueues() {
  if (map.usesKeyReferences()) {
    drainKeyReferenceQueue();
  }
  if (map.usesValueReferences()) {
    drainValueReferenceQueue();
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Drain the key and value reference queues, cleaning up internal entries containing garbage
 * collected keys or values.
 */
@GuardedBy("Segment.this")
void drainReferenceQueues() {
 if (map.usesKeyReferences()) {
  drainKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  drainValueReferenceQueue();
 }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/** Clears all entries from the key and value reference queues. */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/** Clears all entries from the key and value reference queues. */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Clears all entries from the key and value reference queues.
 */
void clearReferenceQueues() {
 if (map.usesKeyReferences()) {
  clearKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  clearValueReferenceQueue();
 }
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Drain the key and value reference queues, cleaning up internal entries containing garbage
 * collected keys or values.
 */
@GuardedBy("this")
void drainReferenceQueues() {
 if (map.usesKeyReferences()) {
  drainKeyReferenceQueue();
 }
 if (map.usesValueReferences()) {
  drainValueReferenceQueue();
 }
}

相关文章

微信公众号

最新文章

更多