FifoBuffer - apache 通用集合 4 替换
FifoBuffer - apache common collections 4 replacements
我想升级到 apache.commons.collections4,但是一些 类 作为 CircularFifoBuffer
和 UnboundedFifoBuffer
被删除了
import org.apache.commons.collections.buffer.CircularFifoBuffer;
这种 类 的正确替代品是什么?
找到几个suggestions:
hadJan Haderka
Or perhaps there's yet another option:
replace buffer with MinMaxPriorityQueue which on it's own is also not thread safe, but guava fortunately provides wrapper for thread safety in form of Queues.synchronizedQueue(Queue q) call. Since we use guava elsewhere already it should be ok to use the library instead of commons. Not sure about performance comparison of the two tho.
Cedric Reichenbach
it seems like Queues#synchronizedQueue is indeed the equivalent of BufferUtils#synchronizedBuffer, i.e. synchronizes every access to the contained queue/buffer. However, a more precise match in Guava for CircularFifoBuffer would probably be EvictingQueue, or, since the sync wrapper works for any Queue, even Java's own Apache's new CircularFifoQueue.
我没有在 mailing list or release notes
中找到答案
在任务 COLLECTIONS-432 中找到答案
将 Buffer 接口替换为 java.util.Queue
BoundedFifoBuffer is replaced with java.util.concurrent.ArrayBlockingQueue
CircularFifoBuffer is replaced with
java.util.concurrent.ArrayBlockingQueue.
PredicatedBuffer transfered into PredivatedBuffer
PriorityBuffer is replaced with java.util.PriorityQueue
SynchronizedBuffer is replaced with
java.util.concurrent.SynchronizedQueue
BlockingBuffer is replaced with java.util.concurrent.BlockingQueue
(practical java.util.concurrent.ArrayBlockingQueue or
java.util.concurrent.SynchronizedQueue)
BoundedBuffer is replaced with java.util.concurrent.ArrayBlockingQueue
TransformedBuffer transfered into TransformedQueue
UnboundedFifoBuffer is replaced with
java.util.concurrent.ArrayBlockingQueue
我想升级到 apache.commons.collections4,但是一些 类 作为 CircularFifoBuffer
和 UnboundedFifoBuffer
被删除了
import org.apache.commons.collections.buffer.CircularFifoBuffer;
这种 类 的正确替代品是什么?
找到几个suggestions:
hadJan Haderka
Or perhaps there's yet another option:
replace buffer with MinMaxPriorityQueue which on it's own is also not thread safe, but guava fortunately provides wrapper for thread safety in form of Queues.synchronizedQueue(Queue q) call. Since we use guava elsewhere already it should be ok to use the library instead of commons. Not sure about performance comparison of the two tho.
Cedric Reichenbach
it seems like Queues#synchronizedQueue is indeed the equivalent of BufferUtils#synchronizedBuffer, i.e. synchronizes every access to the contained queue/buffer. However, a more precise match in Guava for CircularFifoBuffer would probably be EvictingQueue, or, since the sync wrapper works for any Queue, even Java's own Apache's new CircularFifoQueue.
我没有在 mailing list or release notes
中找到答案在任务 COLLECTIONS-432 中找到答案 将 Buffer 接口替换为 java.util.Queue
BoundedFifoBuffer is replaced with java.util.concurrent.ArrayBlockingQueue
CircularFifoBuffer is replaced with java.util.concurrent.ArrayBlockingQueue.
PredicatedBuffer transfered into PredivatedBuffer
PriorityBuffer is replaced with java.util.PriorityQueue
SynchronizedBuffer is replaced with java.util.concurrent.SynchronizedQueue
BlockingBuffer is replaced with java.util.concurrent.BlockingQueue (practical java.util.concurrent.ArrayBlockingQueue or java.util.concurrent.SynchronizedQueue)
BoundedBuffer is replaced with java.util.concurrent.ArrayBlockingQueue
TransformedBuffer transfered into TransformedQueue
UnboundedFifoBuffer is replaced with java.util.concurrent.ArrayBlockingQueue