()
| 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 |
nothing calls this directly
no test coverage detected