[erlang-questions] Writers Readers problem

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Fri Feb 3 16:34:54 CET 2012


On 1/31/12 4:12 PM, Garrett Smith wrote:
> This sounds like a registered process (e.g. gen_server) that manages
> the token. It's user facing API might look like this:
>
> acquire_token() ->  {ok, Token} | timeout
> acquire_token(Timeout) ->  {ok, Token} | timeout
> release_token(Token)
> is_token_valid(Token) ->  boolean()
In addition, the gen_server could set a monitor on the process that 
acquires the token so if the worker dies, then the token is given back 
to the queue. I don't think it is a bad idea to have a single process 
since the token operations are supposed to take very little time anyway 
and you need a serious amount of run on this token system before its 
performance limits will emerge.

-- 
Jesper Louis Andersen
   Erlang Solutions Ltd., Copenhagen, DK




More information about the erlang-questions mailing list