<div>That's what I've implemented at the first place Tony. </div><div>But I like Alex's idea too.</div><div><br></div><div>/Frank</div><div><br></div><div><br></div><div><div class="gmail_quote"><div>Le ven. 9 juin 2017 à 12:33, Tony Rogvall <<a href="mailto:tony@rogvall.se">tony@rogvall.se</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On 9 jun 2017, at 08:08, Alex S. <<a href="mailto:alex0player@gmail.com" target="_blank">alex0player@gmail.com</a>> wrote:<br>
><br>
> Sounds right to me, with the caveat that read + reset to zero can lose some data if you are preempted between those two calls. My usual approach is read and decrement by -N, where N is the value I just read.<br>
<br>
When counter is none negative this can be done atomically like:<br>
<br>
hd(ets:update_counter(Tab, Key, [{Pos,0},{Pos,0,0,0}])).<br>
<br>
/Tony<br>
<br>
>> 9 июня 2017 г., в 8:44, Frank Muller <<a href="mailto:frank.muller.erl@gmail.com" target="_blank">frank.muller.erl@gmail.com</a>> написал(а):<br>
>><br>
>> Hi Everyone,<br>
>><br>
>> I've some troubles to understand the optimal settings for this little simple problem:<br>
>><br>
>> Two Erlang processes A and B.<br>
>><br>
>> 1. Process A randomly increments a counter during its lifetime using "ets:update_counter/3"<br>
>><br>
>> 2. Process B reads the counter every X seconds and reset it to 0.<br>
>><br>
>> I decided to use these options when creating the table:<br>
>><br>
>> {write_concurrency, true}, %% A and B<br>
>> {read_concurrency, false} %% only B<br>
>><br>
>> Are these settings correct and more importantly "optimal" (please elaborate your answer)?<br>
>><br>
>> /Frank<br>
>> _______________________________________________<br>
>> erlang-questions mailing list<br>
>> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote></div></div>