Refine search
@GuardedBy("this") void enqueueNotification( @Nullable K key, int hash, @Nullable V value, int weight, RemovalCause cause) { totalWeight -= weight; if (cause.wasEvicted()) { statsCounter.recordEviction(); } if (map.removalNotificationQueue != DISCARDING_QUEUE) { RemovalNotification<K, V> notification = RemovalNotification.create(key, value, cause); map.removalNotificationQueue.offer(notification); } }
@GuardedBy("Segment.this") @Nullable ReferenceEntry<K, V> removeValueFromChain(ReferenceEntry<K, V> first, ReferenceEntry<K, V> entry, @Nullable K key, int hash, ValueReference<K, V> valueReference, RemovalCause cause) { enqueueNotification(key, hash, valueReference, cause); writeQueue.remove(entry); accessQueue.remove(entry); if (valueReference.isLoading()) { valueReference.notifyNewValue(null); return first; } else { return removeEntryFromChain(first, entry); } }
@ThreadSafe final class SpilledLookupSourceHandle @GuardedBy("this") private State state = State.SPILLED; @GuardedBy("this") @Nullable private SettableFuture<Supplier<LookupSource>> unspilledLookupSource;
@GuardedBy("Segment.this") void removeCollectedEntry(ReferenceEntry<K, V> entry) { enqueueNotification(entry, RemovalCause.COLLECTED); writeQueue.remove(entry); accessQueue.remove(entry); }
@GuardedBy("evictionLock") private void evict() { // Attempts to evict entries from the map if it exceeds the maximum // capacity. If the eviction fails due to a concurrent removal of the // victim, that removal may cancel out the addition that triggered this // eviction. The victim is eagerly unlinked before the removal task so // that if an eviction is still required then a new victim will be chosen // for removal. while (hasOverflowed()) { final Node<K, V> node = evictionDeque.poll(); // If weighted values are used, then the pending operations will adjust // the size to reflect the correct weight if (node == null) { return; } // Notify the listener only if the entry was evicted if (data.remove(node.key, node)) { pendingNotifications.add(node); } makeDead(node); } }
/** * Just hold an object. * @param <T> the type of object */ private class ObjectHolder<T> { private T object; ObjectHolder() { } public T getObject() { return object; } public void setObject(T object) { this.object = object; } }
@GuardedBy("hudson.model.Queue.lock") @Override public long check(Computer c) { return 60; } @Override
@GuardedBy("Segment.this") void expireEntries(long now) { drainRecencyQueue(); ReferenceEntry<K, V> e; while ((e = writeQueue.peek()) != null && map.isExpired(e, now)) { if (!removeEntry(e, e.getHash(), RemovalCause.EXPIRED)) { throw new AssertionError(); } } while ((e = accessQueue.peek()) != null && map.isExpired(e, now)) { if (!removeEntry(e, e.getHash(), RemovalCause.EXPIRED)) { throw new AssertionError(); } } }
@GuardedBy("this") void enqueueNotification( @Nullable K key, int hash, @Nullable V value, int weight, RemovalCause cause) { totalWeight -= weight; if (cause.wasEvicted()) { statsCounter.recordEviction(); } if (map.removalNotificationQueue != DISCARDING_QUEUE) { RemovalNotification<K, V> notification = RemovalNotification.create(key, value, cause); map.removalNotificationQueue.offer(notification); } }
@GuardedBy("Segment.this") @Nullable ReferenceEntry<K, V> removeValueFromChain(ReferenceEntry<K, V> first, ReferenceEntry<K, V> entry, @Nullable K key, int hash, ValueReference<K, V> valueReference, RemovalCause cause) { enqueueNotification(key, hash, valueReference, cause); writeQueue.remove(entry); accessQueue.remove(entry); if (valueReference.isLoading()) { valueReference.notifyNewValue(null); return first; } else { return removeEntryFromChain(first, entry); } }
@ThreadSafe public class PagesSpatialIndexFactory private final List<Type> outputTypes; @GuardedBy("this") private final List<SettableFuture<PagesSpatialIndex>> pagesSpatialIndexFutures = new ArrayList<>(); @GuardedBy("this") @Nullable private Supplier<PagesSpatialIndex> pagesSpatialIndex;
@GuardedBy("this") void removeCollectedEntry(ReferenceEntry<K, V> entry) { enqueueNotification(entry, RemovalCause.COLLECTED); writeQueue.remove(entry); accessQueue.remove(entry); }
/** * Evicts entries from the map while it exceeds the capacity and appends * evicted entries to the notification queue for processing. */ @GuardedBy("evictionLock") void evict() { // Attempts to evict entries from the map if it exceeds the maximum // capacity. If the eviction fails due to a concurrent removal of the // victim, that removal may cancel out the addition that triggered this // eviction. The victim is eagerly unlinked before the removal task so // that if an eviction is still required then a new victim will be chosen // for removal. while (hasOverflowed()) { final Node<K, V> node = evictionDeque.poll(); // If weighted values are used, then the pending operations will adjust // the size to reflect the correct weight if (node == null) { return; } // Notify the listener only if the entry was evicted if (data.remove(node.key, node)) { pendingNotifications.add(node); } makeDead(node); } }
@ThreadSafe private static class OuterPositionTracker @GuardedBy("this") private final boolean[] visitedPositions; @GuardedBy("this") private boolean finished;
/** * This method will be called periodically to allow this strategy to decide what to do with it's owning agent. * * @param c {@link Computer} for which this strategy is assigned. This computer may be online or offline. * This object also exposes a bunch of properties that the callee can use to decide what action to take. * @return The number of minutes after which the strategy would like to be checked again. The strategy may be * rechecked earlier or later that this! */ @GuardedBy("hudson.model.Queue.lock") public abstract long check(@Nonnull T c);
@GuardedBy("this") void enqueueNotification( @Nullable K key, int hash, @Nullable V value, int weight, RemovalCause cause) { totalWeight -= weight; if (cause.wasEvicted()) { statsCounter.recordEviction(); } if (map.removalNotificationQueue != DISCARDING_QUEUE) { RemovalNotification<K, V> notification = RemovalNotification.create(key, value, cause); map.removalNotificationQueue.offer(notification); } }