On 2 Aug 2016, at 06:05, Arindam Mukherjee <arindam....@gmail.com> wrote:I have a requirement where multiple futures will be updating a shared data structure, and this update needs to be synchronized. In some cases, this can happen asynchronously and in some cases this needs to happen synchronously.
Can I use Concurrent Agent and Concurrent Atom for the purpose?
Are Agent#send calls serialized with respect to other send calls on the same instance?
Atom#swap calls don't seem to be serialized. But is compare_and_set serialized - for any complex object that defines equality meaningful equality semantics?
Arindam--
You received this message because you are subscribed to the Google Groups "Concurrent Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concurrent-ru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am sorry, hit reply instead of reply all.
On 2 Aug 2016, at 17:04, Arindam Mukherjee <arindam....@gmail.com> wrote:
On Aug 2, 2016 20:21, "Chris Seaton" <chrisg...@gmail.com> wrote:
>
>
> > On 2 Aug 2016, at 15:19, Arindam Mukherjee <arindam....@gmail.com> wrote:
> >
> > Under what circumstances would the block be run multiple times?
> ...
>
>
> So the block can be re-run if someone else modifies it between your block starting and finishing.
>Cool. So that's a CAS spin lock. When I do:
atom.swap {|val, *args| ...}
what's the old / reference value, which if changed results in a retry?
val is the current value at the time of the block starting. If there is a value older than that you aren’t told about it.I didn’t mean to take this off list by the way.>
> Have you tried just using a big lock?
>Yes that's what I will use.