Reputation: 26882
I was wondering if there are any open source (or proprietary) frameworks that would simulate a concurrent priority queue which allows peeking, and removal from arbitrary index with good performance.
Right now I'm using ConcurrentSkipList
available in JDK, but basically I need to share this across multiple JVMs.
The most difficult part is, when I poll the queue I'm doing something like this:
List<Entry> dequeued = new ArrayList<>(thisManyIwant);
for(Entry entry : queue){
if(dequeued.size()>=thisManyIwant) break;
if(predicate.apply(entry)){
// Entry satisfies criteria
if(queue.remove(entry){
// OK, got it
dequeued.add(entry);
}else{
// damn, somebody took it before I could :(
}
}else{
// It's not something I want, move on to the next one.
}
}
return dequeued;
Some distributed cache allows querying, but this operation is performance intensive and I wasn't sure if querying the cache a lot would be a good idea.
Does anybody have heard of such thing?
Upvotes: 1
Views: 120
Reputation: 28069
Have you looked at Hazelcast
I'm affraid I've only used the Map implementation so I don't know if it supports the pattern you require.
Upvotes: 2