// Copy the message data to the out-queue. func (p *Pumper) Output(t MsgType, m Msg) { cp := bufpool.Get(len(m)) copy(cp, m) select { case p.wQ <- msgEntry{t, cp}: atomic.AddInt64(&p.stat.OutTotal, 1) case <-p.stopD: bufpool.Put(cp) } }
// Try copy the message data to the out-queue. func (p *Pumper) TryOutput(t MsgType, m Msg) bool { cp := bufpool.Get(len(m)) copy(cp, m) select { case p.wQ <- msgEntry{t, cp}: atomic.AddInt64(&p.stat.OutTotal, 1) return true default: bufpool.Put(cp) return false } }