func (mb *MB) WaitMinMax(min, max int) (msgs []interface{}) {
	if min <= 0 {
		min = 1
	}
	mb.cond.L.Lock()
try:
	if len(mb.msgs) < min || mb.paused {
		if mb.closed {
			mb.cond.L.Unlock()
			return
		}
		mb.cond.Wait()
		goto try
	}
	if max > 0 && len(mb.msgs) > max {
		msgs = mb.msgs[:max]
		mb.msgs = mb.msgs[max:]
	} else {
		msgs = mb.msgs
		mb.msgs = make([]interface{}, 0)
	}
	mb.getCount++
	mb.getMsgsCount += int64(len(msgs))
	mb.unlockAdd()
	mb.cond.L.Unlock()
	return
}
WaitMinMax it's Wait with limit of minimum and maximum returning array size
value < 0 means no limit
package mb
import (
	"errors"
	"sync"
)
var ErrClosed = errors.New("mb: MB closed")
var ErrTooManyMessages = errors.New("mb: too many messages")
var ErrOverflowed = errors.New("mb: overflowed")
func New(size int) *MB {
	return &MB{
		cond: sync.NewCond(&sync.Mutex{}),
		size: size,
		read: make(chan struct{}),
	}
}
type MB struct {
	msgs []interface{}
	cond *sync.Cond
	size int
	wait int
	read chan struct{}
	paused, closed bool
	addCount, getCount         int64
	addMsgsCount, getMsgsCount int64
}
func (mb *MB) Wait() (msgs []interface{}) {
	return mb.WaitMinMax(0, 0)
}
func (mb *MB) WaitMax(max int) (msgs []interface{}) {
	return mb.WaitMinMax(0, max)
}
func (mb *MB) WaitMin(min int) (msgs []interface{}) {
	return mb.WaitMinMax(min, 0)
}