code: func (s *StanServer) collectSentOrAck(sub *subState, sent bool, sequence uint64) {
  	sr := s.ssarepl
  	if sub.replicate == nil {
  		sub.replicate = &subSentAndAck{
  			sent: make([]uint64, 0, 100),
  			ack:  make([]uint64, 0, 100),
  		}
  	}
  	r := sub.replicate
  	if sent {
  		r.sent = append(r.sent, sequence)
  	} else {
  		r.ack = append(r.ack, sequence)
  	}
  	// This function is called with exactly one event at a time.
  	// Use exact count to decide when to add to given map. This
  	// avoid the need for booleans to not add more than once.
  	l := len(r.sent) + len(r.ack)
  	if l == 1 {
  		sr.waiting.Store(sub, struct{}{})
  	} else if l == 100 {
  		sr.waiting.Delete(sub)
  		sr.ready.Store(sub, struct{}{})
  		signalCh(sr.notifyCh)
  	}
  }
docs: // Keep track of sent or ack messages.
  // If the number of operations reach a certain threshold,
  // the sub is added to list of subs that should be flushed asap.
  // This call does not do actual RAFT replication and should not block.
  // Caller holds the sub's Lock.