public class MemorySafeLinkedBlockingQueue<E> extends LinkedBlockingQueue<E>
LinkedBlockingQueue,
does not depend on Instrumentation and is easier to use than
MemoryLimitedLinkedBlockingQueue.| Modifier and Type | Field and Description |
|---|---|
static int |
THE_256_MB |
| Constructor and Description |
|---|
MemorySafeLinkedBlockingQueue() |
MemorySafeLinkedBlockingQueue(Collection<? extends E> c,
int maxFreeMemory) |
MemorySafeLinkedBlockingQueue(long maxFreeMemory) |
| Modifier and Type | Method and Description |
|---|---|
long |
getMaxFreeMemory()
get the max free memory.
|
boolean |
hasRemainedMemory()
determine if there is any remaining free memory.
|
boolean |
offer(E e) |
boolean |
offer(E e,
long timeout,
TimeUnit unit) |
void |
put(E e) |
void |
setMaxFreeMemory(int maxFreeMemory)
set the max free memory.
|
void |
setRejector(Rejector<E> rejector)
set the rejector.
|
clear, contains, drainTo, drainTo, iterator, peek, poll, poll, remainingCapacity, remove, size, spliterator, take, toArray, toArray, toStringadd, addAll, element, removecontainsAll, isEmpty, removeAll, retainAllequals, getClass, hashCode, notify, notifyAll, wait, wait, waitaddaddAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, streampublic MemorySafeLinkedBlockingQueue()
public MemorySafeLinkedBlockingQueue(long maxFreeMemory)
public MemorySafeLinkedBlockingQueue(Collection<? extends E> c, int maxFreeMemory)
public void setMaxFreeMemory(int maxFreeMemory)
maxFreeMemory - the max free memorypublic long getMaxFreeMemory()
public void setRejector(Rejector<E> rejector)
rejector - the rejectorpublic boolean hasRemainedMemory()
public void put(E e) throws InterruptedException
put in interface BlockingQueue<E>put in class LinkedBlockingQueue<E>InterruptedExceptionpublic boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<E>offer in class LinkedBlockingQueue<E>InterruptedExceptionpublic boolean offer(E e)
offer in interface BlockingQueue<E>offer in interface Queue<E>offer in class LinkedBlockingQueue<E>Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.