anchor.diff: +%% @author Magnus Klaar <magnus.klaar@gmail.com>
  +%% @doc Request queue for peers
  +%% This module provides a wrapper for the queue module from stdlib, it
  +%% assumes that responses to chunk requests are delivered in the same
  +%% order as they were sent.
  +%%
  +%% The module provides additional functions for validating incoming
  +%% requests against the head of the queue. We want to verify that the
  +%% piece, offset and chunk length matches. We also want to be able to
  +%% detect if the piece and offset but not the chunk length matches.
  +%%
  +%% The module also provides additional functions for checking if the
  +%% request pipeline needs to be refilled or not. The thresholds are
  +%% encapsulated in the request queue.
  +%% @end
   -module(etorrent_rqueue).
   
   -export([new/0,
  +         new/2,
            push/4,
            pop/1,
            peek/1,
            size/1,
            is_head/4,
  -         has_offset/3]).
  +         has_offset/3,
  +         is_low/1,
  +         needs/1]).
   
   
   -type pieceindex() :: etorrent_types:piece_index().
  
positive.code:      ?_assertNot(?rqueue:has_offset(0, 2, Q1)),
       ?_assertNot(?rqueue:has_offset(1, 1, Q1))].
  
  
  
  -endif.
  
negative.code: -type requestspec() :: {pieceindex(), chunkoffset(), chunklength()}.
  
  -record(requestqueue, {
      low_limit  :: non_neg_integer(),
      high_limit :: pos_integer(),
      queue :: queue()}).
  -opaque requestqueue() :: #requestqueue{}.
  
  
  %% @doc Create an empty request queue with default pipeline thresholds
  %% @end
  -spec new() -> requestqueue().
  new() ->
      new(2, 10).
  
  
  %% @doc Create an empty request queue and specify pipeline thresholds
  %% @end
  -spec new(non_neg_integer(), pos_integer()) -> requestqueue().
  new(Lowthreshold, Highthreshold) ->
      InitQueue = #requestqueue{
          low_limit=Lowthreshold,
          high_limit=Highthreshold,
          queue=queue:new()},
      InitQueue.
  
  
  %% @doc
  %% @end
  