public void detachView() { if (mViewRef != null) { mViewRef.clear(); mViewRef = null; } }
public void detachView() { if (mViewRef != null) { mViewRef.clear(); mViewRef = null; } }
/** * Repeatedly dequeues references from the queue and invokes {@link * FinalizableReference#finalizeReferent()} on them until the queue is empty. This method is a * no-op if the background thread was created successfully. */ void cleanUp() { if (threadStarted) { return; } Reference<?> reference; while ((reference = queue.poll()) != null) { /* * This is for the benefit of phantom references. Weak and soft references will have already * been cleared by this point. */ reference.clear(); try { ((FinalizableReference) reference).finalizeReferent(); } catch (Throwable t) { logger.log(Level.SEVERE, "Error cleaning up after reference.", t); } } }
public Object setValue(Object object) { Object old = getValue(); if (valueType > HARD) ((Reference)value).clear(); value = toReference(valueType, object, hash); return old; }
reference.clear();
/** * Called from RequestVariable.shutdown() to unschedule the task. */ public void shutdown() { RequestBatch<BatchReturnType, ResponseType, RequestArgumentType> currentBatch = batch.getAndSet(null); if (currentBatch != null) { currentBatch.shutdown(); } if (timerListenerReference.get() != null) { // if the timer was started we'll clear it so it stops ticking timerListenerReference.get().clear(); } }
public Object setValue(Object object) { Object old = getValue(); if (valueType > HARD) ((Reference)value).clear(); value = toReference(valueType, object, hash); return old; }
/** * Repeatedly dequeues references from the queue and invokes {@link * FinalizableReference#finalizeReferent()} on them until the queue is empty. This method is a * no-op if the background thread was created successfully. */ void cleanUp() { if (threadStarted) { return; } Reference<?> reference; while ((reference = queue.poll()) != null) { /* * This is for the benefit of phantom references. Weak and soft references will have already * been cleared by this point. */ reference.clear(); try { ((FinalizableReference) reference).finalizeReferent(); } catch (Throwable t) { logger.log(Level.SEVERE, "Error cleaning up after reference.", t); } } }
private void processDeadPortals() throws IOException { Reference<? extends Portal> deadPortal; while ((deadPortal = openPortalCleanupQueue.poll()) != null) { String portalName = openPortalMap.remove(deadPortal); sendClosePortal(portalName); deadPortal.clear(); } }
private void processDeadParsedQueries() throws IOException { Reference<? extends SimpleQuery> deadQuery; while ((deadQuery = parsedQueryCleanupQueue.poll()) != null) { String statementName = parsedQueryMap.remove(deadQuery); sendCloseStatement(statementName); deadQuery.clear(); } }
public Object setValue(final Object object) { final Object old = getValue(); if (valueType > HARD) { ((Reference) value).clear(); } value = toReference(valueType, object, hash); return old; }
/** * Poke into the Cache internals to simulate garbage collection of the given key. This assumes * that the given entry is a weak or soft reference, and throws an IllegalStateException if that * assumption does not hold. */ @SuppressWarnings("unchecked") // the instanceof check and the cast generate this warning static <K, V> void simulateKeyReclamation(Cache<K, V> cache, K key) { ReferenceEntry<K, V> entry = getReferenceEntry(cache, key); Preconditions.checkState(entry instanceof Reference); Reference<?> ref = (Reference<?>) entry; if (ref != null) { ref.clear(); } }
@Override public void onError(Throwable e) { if (isNotTimedOut()) { // stop timer and pass notification through tl.clear(); child.onError(e); } }
@Override public void onCompleted() { if (isNotTimedOut()) { // stop timer and pass notification through tl.clear(); child.onCompleted(); } }
/** * Sets the value of the entry. * * @param obj the object to store * @return the previous value */ public Object setValue(Object obj) { Object old = getValue(); if (parent.valueType > HARD) { ((Reference)value).clear(); } value = toReference(parent.valueType, obj, hashCode); return old; }
/** * Sets the value of the entry. * * @param obj the object to store * @return the previous value */ public Object setValue(Object obj) { Object old = getValue(); if (parent.valueType > HARD) { ((Reference)value).clear(); } value = toReference(parent.valueType, obj, hashCode); return old; }
private void handleCommandEnd(boolean commandExecutionStarted) { Reference<TimerListener> tl = timeoutTimer.get(); if (tl != null) { tl.clear(); } long userThreadLatency = System.currentTimeMillis() - commandStartTimestamp; executionResult = executionResult.markUserThreadCompletion((int) userThreadLatency); if (executionResultAtTimeOfCancellation == null) { metrics.markCommandDone(executionResult, commandKey, threadPoolKey, commandExecutionStarted); } else { metrics.markCommandDone(executionResultAtTimeOfCancellation, commandKey, threadPoolKey, commandExecutionStarted); } if (endCurrentThreadExecutingCommand != null) { endCurrentThreadExecutingCommand.call(); } }
/** * Poke into the Cache internals to simulate garbage collection of the value associated with the * given key. This assumes that the associated entry is a WeakValueReference or a * SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if * that assumption does not hold. */ @SuppressWarnings("unchecked") // the instanceof check and the cast generate this warning static <K, V> void simulateValueReclamation(Cache<K, V> cache, K key) { ReferenceEntry<K, V> entry = getReferenceEntry(cache, key); if (entry != null) { ValueReference<K, V> valueRef = entry.getValueReference(); // fail on strong/computing refs Preconditions.checkState(valueRef instanceof Reference); Reference<V> ref = (Reference<V>) valueRef; if (ref != null) { ref.clear(); } } }
private void cleanUpAfterResponseFromCache(boolean commandExecutionStarted) { Reference<TimerListener> tl = timeoutTimer.get(); if (tl != null) { tl.clear(); } final long latency = System.currentTimeMillis() - commandStartTimestamp; executionResult = executionResult .addEvent(-1, HystrixEventType.RESPONSE_FROM_CACHE) .markUserThreadCompletion(latency) .setNotExecutedInThread(); ExecutionResult cacheOnlyForMetrics = ExecutionResult.from(HystrixEventType.RESPONSE_FROM_CACHE) .markUserThreadCompletion(latency); metrics.markCommandDone(cacheOnlyForMetrics, commandKey, threadPoolKey, commandExecutionStarted); eventNotifier.markEvent(HystrixEventType.RESPONSE_FROM_CACHE, commandKey); }