SimpleRegistry(WatchableRegistrationContainer registrationContainer, long timeout, TimeUnit unit) { referenceQueue = new FinalizableReferenceQueue(); this.registrationContainer = registrationContainer; //TODO test performance of the linked vs. array or any other blocking. may provide a new builder feature to setup the size of the queue registryActionQueue = new LinkedBlockingQueue<>(); Thread registryActionThread = new Thread(new RegistryActionHandler(registryActionQueue), "yar-action-handler"); registryActionThread.setDaemon(true); registryActionThread.start(); this.defaultTimeOut = timeout; this.defaultTimeoutUnit = unit; }
GuavaObjectCache(final FinalizableReferenceQueue queue) { super(CacheBuilder.newBuilder().softValues().build(), queue); }
GuavaObjectCache(final FinalizableReferenceQueue queue, final CacheBuilderSpec spec) { super(CacheBuilder.from(spec).build(), queue); }
public SoftKey(final T referent, final FinalizableReferenceQueue queue) { super(requireNonNull(referent), queue); hashCode = referent.hashCode(); }
protected AbstractObjectCache(final Cache<SoftKey<?>, Object> cache, final FinalizableReferenceQueue queue) { this.queue = requireNonNull(queue); this.cache = requireNonNull(cache); }
@Before public void setUp() { queue = new FinalizableReferenceQueue(); oc = new AbstractObjectCache(CacheBuilder.newBuilder().softValues().build(), queue) { }; }
@Before public void setUp() { queue = new FinalizableReferenceQueue(); }
static <T> WatcherRegistration<T> newWatcherRegistration(IdMatcher<T> leftValue, SupplierListener supplierListener, FinalizableReferenceQueue referenceQueue, Registry registry) { return new WatcherRegistration<>(leftValue, supplierListener, new SupplierWatcherToSupplierListenerAdapter<T>(supplierListener), referenceQueue, registry); }
@SuppressWarnings("unchecked") static <T> WatcherRegistration<T> newWatcherRegistration(IdMatcher<T> leftValue, Watcher<T> rightValue, FinalizableReferenceQueue referenceQueue, Registry registry) { return new WatcherRegistration(leftValue, rightValue, new WatcherDecorator<>(rightValue), referenceQueue, registry); }
WatcherRegistration(IdMatcher<T> leftValue, Object weakReference, Watcher<T> rightValue, FinalizableReferenceQueue referenceQueue, Registry registry) { super(weakReference, referenceQueue); left = leftValue; right = rightValue; this.registry = registry; }