Package org.miaixz.bus.core.center.queue
Class CheckedLinkedBlockingQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.LinkedBlockingQueue<E>
org.miaixz.bus.core.center.queue.CheckedLinkedBlockingQueue<E>
- Type Parameters:
E- 对象类型
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,BlockingQueue<E>,Queue<E>
- Direct Known Subclasses:
MemorySafeLinkedBlockingQueue
自定义加入前检查的
LinkedBlockingQueue,给定一个检查函数,在加入元素前检查此函数 原理是通过Runtime#freeMemory()获取剩余内存,当剩余内存低于指定的阈值时,不再加入。- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCheckedLinkedBlockingQueue(Collection<? extends E> c, Predicate<E> checker) 构造CheckedLinkedBlockingQueue(Predicate<E> checker) 构造 -
Method Summary
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
clear, contains, drainTo, drainTo, forEach, iterator, peek, poll, poll, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, take, toArray, toArray, toStringMethods inherited from class java.util.AbstractQueue
add, addAll, element, removeMethods inherited from class java.util.AbstractCollection
containsAll, isEmptyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
addMethods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, stream, toArray
-
Field Details
-
checker
检查函数
-
-
Constructor Details
-
CheckedLinkedBlockingQueue
构造- Parameters:
checker- 检查函数
-
CheckedLinkedBlockingQueue
构造- Parameters:
c- 初始集合checker- 检查函数
-
-
Method Details
-
put
- Specified by:
putin interfaceBlockingQueue<E>- Overrides:
putin classLinkedBlockingQueue<E>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingQueue<E>- Overrides:
offerin classLinkedBlockingQueue<E>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingQueue<E>- Specified by:
offerin interfaceQueue<E>- Overrides:
offerin classLinkedBlockingQueue<E>
-