Re: Safely flush old value out of an atom

2013-09-20 Thread Meikel Brandmeyer (kotarak)
Hi, don't bother. That's perfectly ok, and no, there is no library function for that. I know quite a number of developers having implemented exactly this function (myself included). Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups Clojure

Re: Safely flush old value out of an atom

2013-09-19 Thread Ben Wolfson
Is there some reason you can't use a ref for this? On Thu, Sep 19, 2013 at 9:20 AM, Adam Clements adam.cleme...@gmail.comwrote: Hi, I have been working on a setup where I batch a number of updates in a queue, which I store in an atom with multiple threads potentially adding things to it.

Re: Safely flush old value out of an atom

2013-09-19 Thread Adam Clements
It's possible with a ref, but I don't need to coordinate multiple bits of state so a ref feels like overkill, and it makes adding to the list far more cumbersome as it needs to be inside a dosync, and I essentially end up writing atom-like functions to make that easier... by which point I may as

Re: Safely flush old value out of an atom

2013-09-19 Thread Mikera
Sounds to me like you should use an agent for this. Don't worry about the overhead prematurely, it's actually pretty minimal. Just make sure you choose between send and send-off appropriately (i.e. does your further processing block or not?) On Friday, 20 September 2013 00:20:11 UTC+8, Adam

Safely flush old value out of an atom

2013-09-19 Thread Adam Clements
Hi, I have been working on a setup where I batch a number of updates in a queue, which I store in an atom with multiple threads potentially adding things to it. Periodically I want to flush that queue, leaving an empty list in the atom and passing the current batch of values on for further