anchor.diff:          Q ->
               true = queue:is_queue(Q),
               {{value, Job}, NewQ} = queue:out(Q),
  -
  -            case queue:is_empty(NewQ) of
  +            set_queue(Queue, NewQ),
  +
  +            {ok, Job}
  +    end.
  +
  +dequeue_same_name_jobs(Name, Queue) ->
  +    Jobs = get_state({queue, Queue}, queue:new()),
  +
  +    {Matching, Rest} = out_while(?cut(_#async_job.name =:= Name), Jobs),
  +    set_queue(Queue, Rest),
  +    queue:to_list(Matching).
  +
  +out_while(Pred, Q) ->
  +    out_while(Pred, Q, queue:new()).
  +
  +out_while(Pred, Q, AccQ) ->
  +    case queue:out(Q) of
  +        {empty, _} ->
  +            {AccQ, Q};
  +        {{value, V}, NewQ} ->
  +            case Pred(V) of
                   true ->
  -                    del_state({queue, Queue});
  +                    out_while(Pred, NewQ, queue:in(V, AccQ));
                   false ->
  -                    set_state({queue, Queue}, NewQ)
  -            end,
  -
  -            {ok, Job}
  +                    {AccQ, Q}
  +            end
       end.
   
   maybe_start_job(Queue) ->
  
positive.code:             not_found
      end.
  
  enqueue_job(Queue, Body, HandleResult) ->
      Job = #async_job{body          = Body,
                       handle_result = HandleResult,
                       queue         = Queue},
  
      update_state({queue, Queue},
                   queue:in(Job, _),
                   queue:new()).
  
  dequeue_job(Queue) ->
      case get_state({queue, Queue}) of
  
negative.code: %% gen_server2-specific APIs
  async_job(Body, HandleResult) ->
      Ref = make_ref(),
      async_job(Ref, Ref, Body, HandleResult).
  
  async_job(Queue, Body, HandleResult) ->
      async_job(Queue, make_ref(), Body, HandleResult).
  
  async_job(Queue, Name, Body, HandleResult) ->
      enqueue_job(Queue, Name, Body, HandleResult),
      maybe_start_job(Queue),
      Queue.
  
  