[erlang-questions] compare and set semantics using ets?

Max Lapshin <>
Tue Jan 15 11:52:03 CET 2013


Why are you speaking about some CAS instructions, when you just need API in
ets module: insert_or_replace


On Tue, Jan 15, 2013 at 1:41 PM, Anton Lebedevich <> wrote:

> On 01/14/2013 07:13 PM, Anton Lebedevich wrote:
> > On 01/14/2013 07:01 PM, Jesper Louis Andersen wrote:
> >> On Jan 14, 2013, at 1:08 PM, Anton Lebedevich <> wrote:
> >>
> >>> Is it possible to implement atomic compare-and-set semantics using ets?
> >>
> >> Only in a limited fashion. I guess we either need a specific
> CAS-instruction, or you have to look up how it is achieved in mnesia, which
> does to transactional updates.
> >
> > Good catch, I've completely forgot that mnesia already does it, will
> > take a look at its sources.
>
> Reading mnesia sources revealed that it uses transaction manager and
> locker processes to serialize modification operations.
> Mnesia transactions rely on making modifications sequential not on
> CAS-instructions.
>
> It turns out that CAS which is a workhorse of many non-Erlang concurrent
> libraries isn't available in Erlang without NIFs. Am I missing something?
>
> Regards,
> Anton Lebedevich.
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130115/54e2509d/attachment.html>


More information about the erlang-questions mailing list