anchor.diff:  -include("rexi.hrl").
   -include_lib("eunit/include/eunit.hrl").
   
  +-record(job, {
  +    client::reference(),
  +    worker::reference(),
  +    pid::pid()
  +}).
  +
   -record(st, {
  -    workers = ets:new(workers, [private, {keypos,2}]),
  +    workers = ets:new(workers, [private, {keypos, #job.worker}]),
  +    clients = ets:new(clients, [private, {keypos, #job.client}]),
       errors = queue:new(),
       error_limit = 20,
       error_count = 0
  
positive.code:     lists:map(fun({M,F,A}) when is_list(A) -> {M,F,length(A)}; (X) -> X end,
          erlang:get_stacktrace()).
  
  add_worker(Worker, Tab) ->
      ets:insert(Tab, Worker), Tab.
  
  remove_worker(Ref, Tab) ->
      ets:delete(Tab, Ref), Tab.
  
  find_worker(Ref, Tab) ->
      case ets:lookup(Tab, Ref) of [] -> false; [Worker] -> Worker end.
  
  find_worker_from(Ref, Tab) ->
      case ets:match_object(Tab, {'_', '_', {'_', Ref}}) of
      [] ->
          false;
      [Worker] ->
          Worker
      end.
  
  notify_caller({Caller, Ref}, Reason) ->
      Caller ! {Ref, {rexi_EXIT, Reason}}.
  
negative.code:     {noreply, St}.
  
  terminate(_Reason, St) ->
      ets:foldl(fun(#job{pid=Pid},_) -> exit(Pid,kill) end, nil, St#st.workers),
      ok.
  
  code_change(_OldVsn, {st, Workers}, _Extra) ->
      {ok, #st{workers = Workers}};
  
  code_change(_OldVsn, {st, Workers0, Errors, Limit, Count}, _Extra) ->
      Jobs = [#job{pid=A, worker=B, client=C} || {A, B, {_, C}}
          <- ets:tab2list(Workers0)],
      ets:delete(Workers0),
      State = #st{errors = Errors, error_limit = Limit, error_count = Count},
      ets:insert(State#st.workers, Jobs),
      ets:insert(State#st.clients, Jobs),
      {ok, State};
  
  code_change(_OldVsn, St, _Extra) ->
      {ok, St}.
  