anchor.diff:          timeout
       end.
   
  -produce(Producer, Size) ->
  +produce(Q, Producer, Size, Wait) ->
       Ref = make_ref(),
  +    ItemsCount = couch_work_queue:item_count(Q),
       Producer ! {produce, Ref, Size},
       receive
  +        {item, Ref, Item} when Wait ->
  +            ok = wait_increment(Q, ItemsCount),
  +            Item;
           {item, Ref, Item} ->
               Item
       after ?TIMEOUT ->
  
positive.code:     ?_assertEqual([Item1, Item2, Item3], Items).
  
  should_timeout_on_close_non_empty_queue({Q, Producer, _}) ->
      produce(Producer, 1),
      Status = close_queue(Q),
  
      ?_assertEqual(timeout, Status).
  
  should_not_block_producer_for_non_empty_queue_after_close({Q, Producer, _}) ->
      produce(Producer, 1),
      close_queue(Q),
      Pong = ping(Producer),
      Size = couch_work_queue:size(Q),
  
negative.code:          || {C, Item} <- lists:zip(Consumers, [Item1, Item2, Item3])],
  
      ?_assertEqual([{ok, Item1}, {ok, Item2}, {ok, Item3}], R);
  should_consume_right_item({Q, Producer, Consumer}) ->
      consume(Consumer, 1),
      Item = produce(Q, Producer, 10, false),
      produce(Q, Producer, 20, true),
      ok = ping(Producer),
      ok = ping(Consumer),
      {ok, Items} = last_consumer_items(Consumer),
      ?_assertEqual([Item], Items).
  
  should_increase_queue_size_on_produce({Q, Producer, _}) ->
      produce(Q, Producer, 50, true),
      ok = ping(Producer),
      Count1 = couch_work_queue:item_count(Q),
      Size1 = couch_work_queue:size(Q),
  
      produce(Q, Producer, 10, true),
      Count2 = couch_work_queue:item_count(Q),
      Size2 = couch_work_queue:size(Q),
  
      ?_assertEqual([{Count1, Size1}, {Count2, Size2}], [{1, 50}, {2, 60}]).
  
  should_block_producer_on_full_queue_count({Q, Producer, _}) ->
      produce(Q, Producer, 10, true),
      ?assertEqual(1, couch_work_queue:item_count(Q)),
      ok = ping(Producer),
  
      produce(Q, Producer, 15, true),
      ?assertEqual(2, couch_work_queue:item_count(Q)),
      ok = ping(Producer),
  
      produce(Q, Producer, 20, false),
      ?assertEqual(3, couch_work_queue:item_count(Q)),
      Pong = ping(Producer),
  
      ?_assertEqual(timeout, Pong).
  
  should_block_producer_on_full_queue_size({Q, Producer, _}) ->
      produce(Q, Producer, 100, true),
      ok = ping(Producer),
      ?assertEqual(1, couch_work_queue:item_count(Q)),
      ?assertEqual(100, couch_work_queue:size(Q)),
  
      produce(Q, Producer, 110, false),
      Pong = ping(Producer),
      ?assertEqual(2, couch_work_queue:item_count(Q)),
      ?assertEqual(210, couch_work_queue:size(Q)),
  
      ?_assertEqual(timeout, Pong).
  
  should_consume_multiple_items({Q, Producer, Consumer}) ->
      Item1 = produce(Q, Producer, 10, true),
      ok = ping(Producer),
  
      Item2 = produce(Q, Producer, 15, true),
      ok = ping(Producer),
  
      consume(Consumer, 2),
  