Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2671

MaxOneThreadPerSender creates unnecessary MessageBatch

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 5.2.13
    • None
    • None
    • False
    • None
    • False

      In MaxOneThreadPerSender.submit(MessageBatch batch), we have (edited)

      protected boolean submit(MessageBatch batch) {
          try {
              MessageBatch mb=new MessageBatch(batch.size()).sender(sender).dest(mcast? null : tp.getAddress())
                .clusterName(cluster_name).multicast(mcast);
              mb.add(batch);
              BatchHandlerLoop handler=new BatchHandlerLoop(batch, this, false);
              if(!tp.getThreadPool().execute(handler)) {
                  setRunning(false);
                  return false;
              }
              return true;
           }
      }
      

      The creation of mb is unnecessary here; we can pass batch directly to BatchHandlerLoop. This is possible because batch was created in and populated by the transport, and it won't get reused.

      The savings are one creation of a MessageBatch (includes an array of messages), and more understandable code.

              rhn-engineering-bban Bela Ban
              rhn-engineering-bban Bela Ban
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: