anchor.diff:  wait(Name, _Version) ->
       %% @todo Hopefully, the scheduler will provide enough of a delay.
       erlang:yield(),
  +    %% @todo Warn when NewVersion =:= Version
       ets:lookup_element(Name, version, 2).
   
   
  
positive.code:         {version, 0},
          {limit, Limit},
          {fair, Limit},
          {tokens, 0},
          {timer, TRef}]),
      ok.
  
  
negative.code: take(_N, _Name, infinity, _Version) ->
      ok;
  take(N, Name, Limit, Version) when N >= 0 ->
      case ets:update_counter(Name, tokens, {2,-N}) of
          %% Limit exceeded. Return all tokens and wait for next interval.
          Tokens when Tokens =< 0 ->
              ets:update_counter(Name, tokens, {2,N}),
              NewVersion = wait(Name, Version),
              take(N, Name, Limit, NewVersion);
          Tokens ->
              %% Use difference between the bottom of the bucket and the previous
              %% token count and the packet size to compute the probability of a
              %% message being delayed.
              %% This gives smaller control protocol messages a higher likelyness of
              %% receiving service, avoiding starvation from larger data protocol
              %% messages consuming the rate of entire intervals when a low rate
              %% is used.
              PreviousTokens = Tokens + N,
              case random:uniform(PreviousTokens) of
                  %% Allow message if the random number falls within
                  %% the range of tokens left in the bucket after take.
                  Rand when Rand =< Tokens ->
                      ok;
                   %% Disallow message if the random number falls within
                   %% the range of the tokens taken from the bucket.
                   Rand when Rand > Tokens ->
                      ets:update_counter(Name, tokens, {2,N}),
                      NewVersion = wait(Name, Version),
                      take(N, Name, Limit, NewVersion)
              end
      end.
  