func (p *Pumper) work(ctx context.Context, rwqF context.CancelFunc, sn StopNotifier) { defer p.ending(rwqF, sn) rEvt := p.rQ.Event() for q := false; !q; { select { case <-ctx.Done(): q = true case <-rEvt: e := p.popRMsg() if e != nil { atomic.AddInt64(&p.stat.ProcessN, 1) p.procMsg(ctx, e.id, e.m) poolutil.BufPut(e.m) freeMsgEntry(e) } case <-p.rsD: q = true case <-p.wsD: q = true } } }
func (p *Pumper) bgWrite(ctx context.Context) { defer p.bwEnding() wEvt := p.wQ.Event() for q := false; !q; { select { case <-ctx.Done(): q = true case <-wEvt: e := p.popWMsg() if e != nil { p.backupWMsg(e.id, e.m) atomic.AddInt64(&p.stat.OutN, 1) p.writeMsg(e.id, e.m) poolutil.BufPut(e.m) freeMsgEntry(e) } } } }