interop

2022-06-01T15:23:08.542789Z

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) 2022-06-01T15:37:43.694669Z

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/

2022-06-01T15:38:09.597639Z

Thanks

ghadi 2022-06-01T17:06:27.084849Z

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

2022-06-01T17:13:17.250459Z

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

ghadi 2022-06-01T17:13:51.247899Z

do you need the blocking behavior?

2022-06-01T17:14:03.294799Z

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

ghadi 2022-06-01T17:14:10.617169Z

(of BlockingQueues in j.u.concurrent)

ghadi 2022-06-01T17:14:33.993279Z

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

2022-06-01T17:17:00.253639Z

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.

ghadi 2022-06-01T17:28:40.151059Z

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

2022-06-01T17:29:03.167359Z

yes, that was the problem