anchor.diff:  -behaviour(gen_server).
   
   %% API
  --export([start_link/0]).
  +-export([start_link/0,
  +         clients/0,
  +         register_client/1]).
   
   %% gen_server callbacks
   -export([init/1,
  
positive.code: %%%===================================================================
  %%% Internal functions
  %%%===================================================================
  
negative.code: start_link() ->
      gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
  
  register_client(Pid) ->
      gen_server:call(?MODULE, {register_client, Pid}, infinity).
  
  clients() ->
      gen_server:call(?MODULE, clients, infinity).
  
  
  %%%===================================================================
  %%% gen_server callbacks
  %%%===================================================================
  
  init([]) ->
      Clients = sets:new(),
      {ok, #state{clients=Clients}}.
  
  handle_call(count_clients, _From, State) ->
      Count = count_clients(State#state.clients),
      {reply, {ok, Count}, State};
  handle_call({register_client, Pid}, _From, State) ->
      NewClients = register_client(Pid, State#state.clients),
      {reply, ok, State#state{clients=NewClients}};
  handle_call(_Request, _From, State) ->
      {reply, ok, State}.
  
  