MCPcopy Create free account
hub / github.com/antlr/codebuff / clear

Method clear

corpus/java/training/guava/cache/LocalCache.java:3276–3312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3274 }
3275
3276 void clear() {
3277 if (count != 0) { // read-volatile
3278 lock();
3279 try {
3280 long now = map.ticker.read();
3281 preWriteCleanup(now);
3282
3283 AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table;
3284 for (int i = 0; i < table.length(); ++i) {
3285 for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) {
3286 // Loading references aren't actually in the map yet.
3287 if (e.getValueReference().isActive()) {
3288 K key = e.getKey();
3289 V value = e.getValueReference().get();
3290 RemovalCause cause =
3291 (key == null || value == null) ? RemovalCause.COLLECTED : RemovalCause.EXPLICIT;
3292 enqueueNotification(
3293 key, e.getHash(), value, e.getValueReference().getWeight(), cause);
3294 }
3295 }
3296 }
3297 for (int i = 0; i < table.length(); ++i) {
3298 table.set(i, null);
3299 }
3300 clearReferenceQueues();
3301 writeQueue.clear();
3302 accessQueue.clear();
3303 readCount.set(0);
3304
3305 ++modCount;
3306 count = 0; // write-volatile
3307 } finally {
3308 unlock();
3309 postWriteCleanup();
3310 }
3311 }
3312 }
3313
3314 @GuardedBy("this")
3315 @Nullable

Callers

nothing calls this directly

Calls 15

preWriteCleanupMethod · 0.95
enqueueNotificationMethod · 0.95
clearReferenceQueuesMethod · 0.95
postWriteCleanupMethod · 0.95
getMethod · 0.65
getNextMethod · 0.65
isActiveMethod · 0.65
getValueReferenceMethod · 0.65
getKeyMethod · 0.65
getHashMethod · 0.65
getWeightMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected