MCPcopy
hub / github.com/google/guava / clear

Method clear

guava/src/com/google/common/cache/LocalCache.java:3206–3242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3204 }
3205
3206 void clear() {
3207 if (count != 0) { // read-volatile
3208 lock();
3209 try {
3210 long now = map.ticker.read();
3211 preWriteCleanup(now);
3212
3213 AtomicReferenceArray<ReferenceEntry<K, V>> table = this.table;
3214 for (int i = 0; i < table.length(); ++i) {
3215 for (ReferenceEntry<K, V> e = table.get(i); e != null; e = e.getNext()) {
3216 // Loading references aren't actually in the map yet.
3217 if (e.getValueReference().isActive()) {
3218 K key = e.getKey();
3219 V value = e.getValueReference().get();
3220 RemovalCause cause =
3221 (key == null || value == null) ? RemovalCause.COLLECTED : RemovalCause.EXPLICIT;
3222 enqueueNotification(
3223 key, e.getHash(), value, e.getValueReference().getWeight(), cause);
3224 }
3225 }
3226 }
3227 for (int i = 0; i < table.length(); ++i) {
3228 table.set(i, null);
3229 }
3230 clearReferenceQueues();
3231 writeQueue.clear();
3232 accessQueue.clear();
3233 readCount.set(0);
3234
3235 ++modCount;
3236 count = 0; // write-volatile
3237 } finally {
3238 unlock();
3239 postWriteCleanup();
3240 }
3241 }
3242 }
3243
3244 @GuardedBy("this")
3245 @Nullable ReferenceEntry<K, V> removeValueFromChain(

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