[erlang-questions] ets:update_counter/3 optimal settings
Alex S.
alex0player@REDACTED
Fri Jun 9 08:08:49 CEST 2017
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.
> 9 июня 2017 г., в 8:44, Frank Muller <frank.muller.erl@REDACTED> написал(а):
>
> Hi Everyone,
>
> I've some troubles to understand the optimal settings for this little simple problem:
>
> Two Erlang processes A and B.
>
> 1. Process A randomly increments a counter during its lifetime using "ets:update_counter/3"
>
> 2. Process B reads the counter every X seconds and reset it to 0.
>
> I decided to use these options when creating the table:
>
> {write_concurrency, true}, %% A and B
> {read_concurrency, false} %% only B
>
> Are these settings correct and more importantly "optimal" (please elaborate your answer)?
>
> /Frank
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170609/d05eb453/attachment.htm>
More information about the erlang-questions
mailing list