Fork me on GitHub
#interop
<
2022-06-01
>
Joshua Suskalo15:06:08

Does anyone have recommendations for concurrent queue data structures that allow you to remove the tail iff it's equal to some object? Basically allowing you to CAS the tail? I've been working with the ConcurrentLinkedQueue from the java collections framework, and it kinda works, but the remove method on it doesn't quite match the semantics I want.

Alex Miller (Clojure team)15:06:43

I don't have an answer for you but this mailing list is a place where people discuss such things: http://cs.oswego.edu/pipermail/concurrency-interest/

ghadi17:06:27

you can also use compare-and-swap! directly in clojure

Joshua Suskalo17:06:17

Yeah, although I'm trying to not reimplement a concurrent queue in clojure with atoms

ghadi17:06:51

do you need the blocking behavior?

Joshua Suskalo17:06:03

no, I just need to be able to do atomic removal of elements after I inspect them

ghadi17:06:10

(of BlockingQueues in j.u.concurrent)

ghadi17:06:33

then honestly I'd look at putting a PersistentQueue in an atom, and using cas, not swap

Joshua Suskalo17:06:00

That might be feasible, the main reason I hadn't looked too hard at this is I'm expecting high contention on this queue and so I was looking to j.u.concurrent for mutable implementations to help mitigate that cost.

ghadi17:06:40

j.u.c queues don't allow you to atomically peek at the tail of a queue

Joshua Suskalo17:06:03

yes, that was the problem