[erlang-questions] Thoughts about server abstraction and process management

zambal <>
Thu Mar 26 10:39:06 CET 2009


On Wed, Mar 25, 2009 at 5:34 PM, Ulf Wiger
<> wrote:
zambal wrote:
> You can implement the exact same abstractions
> on top of gen_server. See below.

Yes, I have done that myself too after I realized that I was
essentially trying to rebuild gen_server with a slightly different
interface. The thing is I never knew that you could start a gen_server
without a registered name, because all tutorials I read about
gen_server used registered names. However, later on I realized that a
big disadvantage of using a closure as the interface to a server is
that as far as I can see you can't use type specifications.

So for the fun of it I have been experimenting with a different idiom
too, by putting all api functions of a gen_server callback module
(like do(X, S)-> gen_server:call(S, {do, X}).  etc.)  in a separate
parametrized module. The callback module can instantiate this api
module with it's Pid as parameter, so that you can create and call a
particular instance of a server like this: S = server:new(), S:do(X).
It's not much different from the typical S = server:start(),
server:do(X, S), but the syntax for calling server instance is IMO a
bit more clean.

>> So I was wondering if there ever have been any ideas
>> about process management like how memory is managed in
>> garbage collected languages?
>
> I can recall that the idea has been discussed in the past,
> but for better or for worse, it's rather too late for that.
> It would probably break existing code in gruesome ways.

I can imagine that, but I wasn't suggesting to actually implement
something like this in Erlang, just wondering if their ever has been
any discussion about this, because googling for garbage collected
process management returned no results.

---
vincent



More information about the erlang-questions mailing list