[erlang-questions] How to do counters?

Jarrod Roberson jarrod@REDACTED
Fri Jun 26 00:29:26 CEST 2009


On Wed, Jun 10, 2009 at 1:57 PM, Thomas Lindgren
<thomasl_erlang@REDACTED>wrote:

>
>
>
>
>
> ----- Original Message ----
> > From: Jarrod Roberson <jarrod@REDACTED>
> > To: Erlang <erlang-questions@REDACTED>
> > Sent: Wednesday, June 10, 2009 7:21:20 PM
> > Subject: [erlang-questions] How to do counters?
> >
> > I want to add counters to my gen_tcp implementation to track total
> > number of connections made, total number of requests serviced, total
> > number of bytes transfered, etc.
> > I need to have numbers like this for production monitoring. In python
> > or java I would just have a singleton class that had these counters
> > with thread safe increment/decrement methods. How would I get this
> > same behavior using Erlang?
>
> Two ways:
>
> 1. Your singleton is a registered process, e.g. a gen_server. Write an API
> that sends messages which update the internal state of this process.
>

what do you mean by "internal state" I don't understand how a process would
store any mutable state


More information about the erlang-questions mailing list