def buffer(msg, opts)
      buffer_size = write_to_buffer(msg, opts)
      unless buffer_size.nil?
        process_buffer(buffer_size)
      end
    end
def buffer(msg, opts)
      buffer_size = write_to_buffer(msg, opts)
      unless buffer_size.nil?
        process_buffer(buffer_size)
      end
    end
this should always be running synchronously within this thread