anchor.diff:          not_found ->
               (get_module()):handle_info(Info, State)
       end;
  -handle_info(Info, State) ->
  +do_handle_info(Info, State) ->
       (get_module()):handle_info(Info, State).
   
   terminate(Reason, State) ->
  
positive.code: -export([abort_queue/1, abort_queue/3]).
  -export([get_active_queues/0]).
  
  %% gen_server callbacks
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
           terminate/2, code_change/3]).
  
negative.code:     maybe_start_job(Queue),
  
      chain_handle_results([Job | MoreJobs], Result, State).
  
  add_condition(Pred, OnSuccess, Timeout, OnTimeout) ->
      Id = make_ref(),
  
      Timer0 = misc:create_timer({'$gen_server2', condition_expired, Id}),
      Timer  =
          case Timeout of
              infinity ->
                  true = (OnTimeout =:= undefined),
                  Timer0;
              _ when is_integer(Timeout) ->
                  true = is_function(OnTimeout),
                  misc:arm_timer(Timeout, Timer0)
          end,
  
      Cond =
          #condition{id         = Id,
                     timer      = Timer,
                     pred       = Pred,
                     on_timeout = OnTimeout,
                     on_success = OnSuccess},
  
      update_state(conditions, [Cond | _], []).
  
  take_condition(Id) ->
      case lists:keytake(Id, #condition.id, get_state(conditions)) of
          {value, Cond, Rest} ->
              case Rest of
                  [] ->
                      del_state(conditions);
                  _ ->
                      set_state(conditions, Rest)
              end,
  
              {ok, Cond};
          false ->
              not_found
      end.
  
  handle_condition_expired(Id, State) ->
      {ok, Cond} = take_condition(Id),
      (Cond#condition.on_timeout)(State).
  
  check_conditions(Reply) ->
      case should_check_conditions(Reply) of
          true ->
              Ix    = state_ix(Reply),
              State = element(Ix, Reply),
  
              case check_conditions_with_state(State) of
                  {noreply, NewState} ->
                      setelement(Ix, Reply, NewState);
                  {stop, _, _} = Stop ->
                      Stop
              end;
          false ->
              Reply
      end.
  
  should_check_conditions(Reply) ->
      should_check_conditions_by_tag(element(1, Reply)).
  
  should_check_conditions_by_tag(stop) ->
      false;
  should_check_conditions_by_tag(error) ->
      false;
  should_check_conditions_by_tag(_) ->
      true.
  
  state_ix(Reply) ->
      Tag = element(1, Reply),
      case Tag of
          reply ->
              3;
          noreply ->
              2;
          ok ->
              2
      end.
  
  check_conditions_with_state(State) ->
      {Satisfied, Rest} =
          lists:foldr(fun (Cond, {AccSatisfied, AccRest}) ->
                              case (Cond#condition.pred)(State) of
                                  false ->
                                      {AccSatisfied, [Cond | AccRest]};
                                  Other ->
                                      misc:cancel_timer(Cond#condition.timer),
                                      {[{Cond, Other} | AccSatisfied], AccRest}
                              end
                      end, {[], []}, get_state(conditions, [])),
  
      set_state(conditions, Rest),
      chain_condition_bodies(Satisfied, State).
  
  chain_condition_bodies([], State) ->
      {noreply, State};
  chain_condition_bodies([{Cond, PredResult} | Rest], State) ->
      case (Cond#condition.on_success)(PredResult, State) of
          {noreply, NewState} ->
              chain_condition_bodies(Rest, NewState);
          {stop, _, _} = Stop ->
              Stop
      end.
  