def buffer_receive(event, group=nil)
      buffer_initialize if ! @buffer_state

      # block if we've accumulated too many events
      while buffer_full? do
        on_full_buffer_receive(
          :pending => @buffer_state[:pending_count],
          :outgoing => @buffer_state[:outgoing_count]
        ) if @buffer_config[:has_on_full_buffer_receive]

        if @buffer_config[:drop_messages_on_full_buffer]
          reset_buffer
        else
          sleep 0.1
        end
      end

      @buffer_state[:pending_mutex].synchronize do
        @buffer_state[:pending_items][group] << event
        @buffer_state[:pending_count] += 1
      end

      if @buffer_config[:autoflush]
        buffer_flush(force: true)
      end
    end
def buffer_receive(event, group=nil)
      buffer_initialize if ! @buffer_state

      # block if we've accumulated too many events
      while buffer_full? do
        on_full_buffer_receive(
          :pending => @buffer_state[:pending_count],
          :outgoing => @buffer_state[:outgoing_count]
        ) if @buffer_config[:has_on_full_buffer_receive]

        if @buffer_config[:drop_messages_on_full_buffer]
          reset_buffer
        else
          sleep 0.1
        end
      end

      @buffer_state[:pending_mutex].synchronize do
        @buffer_state[:pending_items][group] << event
        @buffer_state[:pending_count] += 1
      end

      if @buffer_config[:autoflush]
        buffer_flush(force: true)
      end
    end
Save an event for later delivery

 Events are grouped by the (optional) group parameter you provide.
 Groups of events, plus the group name, are later passed to +flush+.

 This call will block if +:max_items+ has been reached.

 @see Stud::Buffer The overview has more information on grouping and flushing.

 @param event An item to buffer for flushing later.
 @param group Optional grouping key. All events with the same key will be
              passed to +flush+ together, along with the grouping key itself.