anchor.diff:  %%%% Functions to handle asynchronous puts
   
   %% Invoked by put/2 to turn the async request into a synchronous call
  -synchronize_put({ok, {ReqId, Worker}}, Options) ->
  -    Timeout = case proplists:get_value(timeout, Options, ?DEFAULT_TIMEOUT) of
  -                  N when is_integer(N) andalso N > 0 ->
  -                      N;
  -                  _ ->
  -                      ?DEFAULT_TIMEOUT
  -              end,
  -    %% this is not direct gen_server:call because the process that
  -    %% replies is not the one that received the cast
  +synchronize_put({ok, {_ReqId, _Worker}=ReqIdTuple}, Options) ->
  +    wait_for_put_reply(ReqIdTuple, find_put_timeout(Options));
  +synchronize_put(Error, _Options) ->
  +    Error.
  +
  +%% Invoked by async_put_reply/2 to wait for all responses
  +async_put_reply_loop([], Responses, _StartTime, _Timeout) ->
  +    Responses;
  +async_put_reply_loop([IdTuple|IdTuples], Responses, StartTime, Timeout) ->
  +    async_put_reply_loop(IdTuples,
  +                         [wait_for_put_reply(IdTuple,
  +                                             remaining_put_timeout(
  +                                               StartTime, Timeout))
  +                          |Responses],
  +                         StartTime, Timeout).
  +
  +wait_for_put_reply({ReqId, Worker}, Timeout) ->
       receive
           {'DOWN', ReqId, process, _Pid, _Reason} ->
               {error, riak_kv_w1c_server_crashed};
  
positive.code:             Error
      end.
  
  -spec async_put_replies(ReqIds :: list({reference(), pid()}), riak_object:options()) ->
                                         list(term()).
  async_put_replies(ReqIds, Options) ->
      Timeout = case proplists:get_value(timeout, Options, ?DEFAULT_TIMEOUT) of
                    N when is_integer(N) andalso N > 0 ->
                        N;
                    _ ->
                        ?DEFAULT_TIMEOUT
                end,
      async_put_reply_loop(ReqIds, [], Timeout).
  
  
  %%%===================================================================
  
negative.code:             erlang:demonitor(ReqId, [flush]),
              Response
      after Timeout ->
              erlang:demonitor(ReqId, [flush]),
              gen_server:cast(Worker, {cancel, ReqId}),
              {error, timeout}
      end.
  
  non_neg(X) ->
      max(0, X).
  
  remaining_put_timeout(Start, Timeout) ->
      non_neg(Timeout -
                  non_neg(trunc(timer:now_diff(os:timestamp(), Start)))).
  
  find_put_timeout(Options) ->
      case proplists:get_value(timeout, Options, ?DEFAULT_TIMEOUT) of
          N when is_integer(N) andalso N > 0 ->
              N;
          _ ->
              ?DEFAULT_TIMEOUT
      end.
  