anchor.diff:       ?_assertNot(?rqueue:has_offset(0, 2, Q1)),
        ?_assertNot(?rqueue:has_offset(1, 1, Q1))].
   
  +low_check_test_() ->
  +    Q0 = ?rqueue:new(1, 3),
  +    Q1 = ?rqueue:push(0, 0, 1, Q0),
  +    Q2 = ?rqueue:push(0, 1, 1, Q1),
  +    [?_assert(?rqueue:is_low(Q0)),
  +     ?_assert(?rqueue:is_low(Q1)),
  +     ?_assertNot(?rqueue:is_low(Q2))].
  +
  +needs_test_() ->
  +    Q0 = ?rqueue:new(1, 3),
  +    Q1 = ?rqueue:push(0, 0, 1, Q0),
  +    Q2 = ?rqueue:push(0, 1, 1, Q1),
  +    Q3 = ?rqueue:push(0, 2, 1, Q2),
  +    Q4 = ?rqueue:push(0, 3, 1, Q3),
  +    [?_assertEqual(3, ?rqueue:needs(Q0)),
  +     ?_assertEqual(2, ?rqueue:needs(Q1)),
  +     ?_assertEqual(1, ?rqueue:needs(Q2)),
  +     ?_assertEqual(0, ?rqueue:needs(Q3)),
  +     ?_assertEqual(0, ?rqueue:needs(Q4))].
   
   
   -endif.
  
positive.code: -module(etorrent_rqueue).
  
  -export([new/0,
           push/4,
           pop/1,
           peek/1,
           size/1,
           is_head/4,
           has_offset/3]).
  
  
  -type pieceindex() :: etorrent_types:piece_index().
  
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
  