anchor.diff:      Cap = Limit * 5,
       ets:update_counter(Name, tokens, {2,Limit,Cap,Cap}).
   
  +
   %% @doc Add the current process as the member of a flow.
   %% The process is removed from the flow when it exists. Exiting is the only
   %% way to remove a member of a flow.
  
positive.code: -spec take(non_neg_integer(), atom()) -> ok.
  take(N, Name) when is_integer(N), N >= 0, is_atom(Name) ->
      Limit = ets:lookup_element(Name, limit, 2),
      take(N, Name, Limit).
  
  take(_N, _Name, infinity) ->
      ok;
  take(N, Name, Limit) when N >= 0 ->
      case ets:update_counter(Name, tokens, {2,N}) of
          %% Limit exceeded. Keep the amount of tokens that we did
          %% manage to take before exceeding the limit.
          Tokens when Tokens >= Limit ->
              Over = Tokens - Limit,
              Under = N - Over,
              %% Hopefully, the scheduler will provide enough of a delay
              %% for the token counter to reset inbetween. If not, we'll
              %% notice this function being called a substantial number
              %% of times more than take/2.
              erlang:yield(),
              take(N-Under, Name, Limit);
          Tokens when Tokens < Limit ->
              %% Use difference between token counter and the token limit
              %% to compute the probability of a message being delayed.
  
negative.code:                     %% Ensure that the token counter is never negative. We will loose
                      %% some tokens if the token counter was reset inbetween.
                      ets:update_counter(Name, tokens, {2,-N,0,0}),
                      NewVersion = wait(Name, Version),
                      take(N, Name, Limit, NewVersion);
                  _ ->
                      ok
              end
  