func (buffer *Buffer) Flush() Payload {
	buffer.Lock()
	defer buffer.Unlock()

	for len(buffer.payload) == 0 && !buffer.closed {
		buffer.flushCondition.Wait()
	}

	length := len(buffer.payload)
	limit := length

	if buffer.flushLimit > 0 && buffer.flushLimit < length && !buffer.closed {
		limit = buffer.flushLimit
	}

	payload := buffer.payload[:limit]

	buffer.payload = buffer.payload[limit:]

	return payload
}
// Flush returns and clears the buffered payload.
// If the buffer is empty, it blocks until at least one packet is present
Flush returns and clears the buffered payload.
If the buffer is empty, it blocks until at least one packet is present
// Flush returns and clears the buffered payload . // If the buffer is empty it blocks until at least one packet is present
func (buffer *Buffer) Flush() Payload {
	buffer.Lock()
	defer buffer.Unlock()
	for len(buffer.payload) == 0 && !buffer.closed {
		buffer.flushCondition.Wait()
	}
	length := len(buffer.payload)
	limit := length
	if buffer.flushLimit > 0 && buffer.flushLimit < length && !buffer.closed {
		limit = buffer.flushLimit
	}
	payload := buffer.payload[:limit]
	buffer.payload = buffer.payload[limit:]
	return payload
}
func ( buffer * Buffer ) Flush ( ) Payload { buffer . Lock ( ) defer buffer . Unlock ( ) for len ( buffer . payload ) == 0 && ! buffer . closed { buffer . flushCondition . Wait ( ) } length := len ( buffer . payload ) limit := length if buffer . flushLimit > 0 && buffer . flushLimit < length && ! buffer . closed { limit = buffer . flushLimit } payload := buffer . payload [ : limit ] buffer . payload = buffer . payload [ limit : ] return payload }
Flush returns and clears the buffered payload.
Flush returns and clears the buffered payload .