/** * Returns the next available reference from the queue, removing it in the * process. Waits indefinitely for a reference to become available. * * @throws InterruptedException if the blocking call was interrupted */ public Reference<? extends T> remove() throws InterruptedException { return remove(0L); }
/** Loops continuously, pulling references off the queue and cleaning them up. */ @SuppressWarnings("InfiniteLoopStatement") @Override public void run() { while (true) { try { if (!cleanUp(queue.remove())) { break; } } catch (InterruptedException e) { // ignore } } }
@Override public void run() { try { while (true) { Reference<? extends Buffer> toclean = BufferUtils.removeCollected.remove(); BufferUtils.trackedBuffers.remove(toclean); } } catch (InterruptedException e) { e.printStackTrace(); } } }
/** Loops continuously, pulling references off the queue and cleaning them up. */ @SuppressWarnings("InfiniteLoopStatement") @Override public void run() { while (true) { try { if (!cleanUp(queue.remove())) { break; } } catch (InterruptedException e) { // ignore } } }
/** Loops continuously, pulling references off the queue and cleaning them up. */ @SuppressWarnings("InfiniteLoopStatement") @Override public void run() { while (true) { try { if (!cleanUp(queue.remove())) { break; } } catch (InterruptedException e) { // ignore } } }
@Override public void run() { while (alive) { try { BufferReference ref = (BufferReference) garbageCollectedBuffers.remove(); //blocks ref.clear(); //this cannot race with a release() call because an object is either reachable or not, //release() can only happen before its GC'ed, and enqueue can only happen after. //if the ref was enqueued it must then not have been released BufferMetadata metadata = buffersInFlight.remove(ref); if (metadata == null) { //it can happen rarely that the buffer was release()ed properly (so no metadata) and yet //the reference object to it remains reachable for a short period of time after release() //and hence gets enqueued. this is because we keep refs in a ConcurrentHashMap which cleans //up keys lazily. continue; } availableMemory.addAndGet(metadata.sizeBytes); log.error("Reclaimed buffer of size {} and identity {} that was not properly release()ed. This is a bug.", metadata.sizeBytes, ref.hashCode); } catch (InterruptedException e) { log.debug("interrupted", e); //ignore, we're a daemon thread } } log.info("GC listener shutting down"); } }
public void run() { AutomaticReference<?> ref; for (;;) try { ref = (AutomaticReference<?>) QUEUE.remove(); try { ref.free(); } finally { LIVE_SET.remove(ref); } } catch (Throwable ignored) { } } }
/** * Free unnecessary LWJGL byte buffers. */ static void freeByteBuffers() { try { for (;;) { final Deallocator deallocator = (Deallocator) DUMMY_QUEUE.remove(); deallocator.free(); } } catch (final InterruptedException e) { e.printStackTrace(); } }
/** Loops continuously, pulling references off the queue and cleaning them up. */ @SuppressWarnings("InfiniteLoopStatement") @Override public void run() { while (true) { try { if (!cleanUp(queue.remove())) { break; } } catch (InterruptedException e) { // ignore } } }
final AutomaticCleanerReference reference; try { reference = (AutomaticCleanerReference) REFERENCE_QUEUE.remove(REFERENCE_QUEUE_POLL_TIMEOUT_MS); } catch (InterruptedException ex) {
private void processFinalizerQueue() { while (!Thread.currentThread().isInterrupted()) { try { FinalizerReference finalizer = (FinalizerReference) finalizerQueue.remove(); finalizers.remove(finalizer); finalizer.cleanup(); } catch (InterruptedException e) { return; } catch (Throwable e) { log.error(e, "Finalizer cleanup failed"); } } }
/** * Start execution. */ public void run() { while (!shutdown) { try { // remove the next reference and process it Reference ref = REFERENCE_QUEUE.remove(); if (ref != null) { handleReference(ref); } } catch (InterruptedException e) { LOG.debug("ReferenceQueueThread interrupted", e); } } }
@Override public void run() { while(true) { try { ThreadWeakRef remove = (ThreadWeakRef)refQ.remove(); removeQueue(remove.r); weakRefHolder.remove(remove); } catch (InterruptedException e) { if (Thread.interrupted()) { return; } } } } };
@Override public void run() { try { while (running) { final PhantomDelegatingCloseableRef toClose = (PhantomDelegatingCloseableRef) referenceQueue.remove(); if (toClose != null) { try { LOG.warn("Closing unclosed resource via safety-net: {}", toClose.getDebugString()); toClose.close(); } catch (Throwable t) { LOG.debug("Error while closing resource via safety-net", t); } } } } catch (InterruptedException e) { // done } }
@Override public void run() { try { while (true) { DeallocatorReference r = (DeallocatorReference)referenceQueue.remove(); r.clear(); r.remove(); } } catch (InterruptedException ex) { // reset interrupt to be nice Thread.currentThread().interrupt(); } } }
@SuppressWarnings("WeakerAccess") @Synthetic void cleanReferenceQueue() { while (!isShutdown) { try { ResourceWeakReference ref = (ResourceWeakReference) resourceReferenceQueue.remove(); cleanupActiveReference(ref); // This section for testing only. DequeuedResourceCallback current = cb; if (current != null) { current.onResourceDequeued(); } // End for testing only. } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
/** * Run the reaper thread that will delete files as their associated * marker objects are reclaimed by the garbage collector. */ @Override public void run() { // thread exits when exitWhenFinished is true and there are no more tracked objects while (exitWhenFinished == false || trackers.size() > 0) { try { // Wait for a tracker to remove. final Tracker tracker = (Tracker) q.remove(); // cannot return null trackers.remove(tracker); if (!tracker.delete()) { deleteFailures.add(tracker.getPath()); } tracker.clear(); } catch (final InterruptedException e) { continue; } } } }
@Override public void run(Publisher<T> pub) throws Throwable { final WeakReference<ManualSubscriber<T>> ref = run.apply(pub); // cancel may be run asynchronously so we add a sleep before running the GC // to "resolve" the race Thread.sleep(publisherReferenceGCTimeoutMillis); System.gc(); if (!ref.equals(queue.remove(100))) { env.flop(String.format("Publisher %s did not drop reference to test subscriber after subscription cancellation", pub)); } env.verifyNoAsyncErrorsNoDelay(); } });
@Override public void run() { while (isRunning()) { // Take a reference, blocking until one is ready or the thread should stop try { doFinalize((FinalizerReference<?>) queue.remove()); } catch (InterruptedException ignored) { } } }
public void run() { for (;;) try { final java.lang.ref.Reference<?> ref = REAPER_QUEUE.remove(); if (ref instanceof CleanerReference) { ((CleanerReference<?, ?>) ref).clean(); } if (ref instanceof Reapable) { reap((Reapable<?, ?>) ref); } } catch (InterruptedException ignored) { // we consume interrupts. } catch (Throwable cause) { Log.log.reapFailed(cause); } }