def borrow_or_take(now, borrowable)
      @lock.synchronize do
        reset_new_sec(now)
        # Don't borrow if the quota is available and fresh.
        if quota_fresh?(now)
          return SamplingDecision::NOT_SAMPLE if @taken_this_sec >= @quota
          @taken_this_sec += 1
          return SamplingDecision::TAKE
        end

        # Otherwise try to borrow if the quota is not present or expired.
        if borrowable
          return SamplingDecision::NOT_SAMPLE if @borrowed_this_sec >= 1
          @borrowed_this_sec += 1
          return SamplingDecision::BORROW
        end

        # Cannot sample if quota expires and cannot borrow
        SamplingDecision::NOT_SAMPLE
      end
    end
def borrow_or_take(now, borrowable)
      @lock.synchronize do
        reset_new_sec(now)
        # Don't borrow if the quota is available and fresh.
        if quota_fresh?(now)
          return SamplingDecision::NOT_SAMPLE if @taken_this_sec >= @quota
          @taken_this_sec += 1
          return SamplingDecision::TAKE
        end

        # Otherwise try to borrow if the quota is not present or expired.
        if borrowable
          return SamplingDecision::NOT_SAMPLE if @borrowed_this_sec >= 1
          @borrowed_this_sec += 1
          return SamplingDecision::BORROW
        end

        # Cannot sample if quota expires and cannot borrow
        SamplingDecision::NOT_SAMPLE
      end
    end
Decide whether to borrow or take one quota from
 the reservoir. Return `false` if it can neither
 borrow nor take. This method is thread-safe.