<div dir="ltr">On 12 October 2017 at 09:01, Benoit Chesneau <span dir="ltr"><<a href="mailto:bchesneau@gmail.com" target="_blank">bchesneau@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I’m looking on the best way (in term of concurrency and response speed) to provide a equivalent of compare-and-swap semantic on differs Erlang version with ETS. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
For now what I do is using `select_replace/2` on OTP 20 and for other versions I’m using a pen_server to serialise the writes on this values, making this gen_server a bottle neck. Which is fine for a small list of keys to update. I didn’t find any other solution to do it right now. But maybe someone has an idea?<br></blockquote><div><br></div><div>The only thing I can think of is to partition the key space and use multiple ETS tables (with a dedicated process for each).</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also something I’m currently missing is the possibility do the dame for delete. `select_delete` isn’t atomic right?<br></blockquote><div><br></div><div>Not sure what you mean by 'atomic' here. I expect ETS will delete whatever entries have matched this specified pattern at that point in time. In the context of ETS operations, the consideration of whether it is 'atomic' or not makes sense in the 'insert', 'replace' or 'update' scenario.</div><div><br></div><div>cheers,</div><div>Chandru</div><div><br></div><div><br></div></div></div></div>