Skip to content

Commit

Permalink
Update rmqperftest_runner.cpp
Browse files Browse the repository at this point in the history
Signed-off-by: Will Hoy <[email protected]>
  • Loading branch information
willhoy authored and adamncasey committed Jan 12, 2024
1 parent 0506890 commit 20ca5fb
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions examples/rmqperftest/rmqperftest_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
namespace BloombergLP {
namespace rmqperftest {
namespace {

typedef bsl::pair<bsl::shared_ptr<rmqa::Producer>, bsl::string>
ProducerRoutingKeyPair;

class ConsumerCallback {
public:
ConsumerCallback(const ConsumerArgs& args,
Expand Down Expand Up @@ -96,6 +100,18 @@ bsl::string_view queueNameOrRoutingKey(bsl::string_view routingKey,
}
}

void finalizeProducers(bsl::vector<ProducerRoutingKeyPair>& producers)
{
bsl::cout << producers.size() << " producers finished, exiting producers"
<< bsl::endl;
for (bsl::vector<ProducerRoutingKeyPair>::iterator it = producers.begin();
it != producers.end();
++it) {
it->first->waitForConfirms();
}
producers.clear();
}

} // namespace

int Runner::run(const PerfTestArgs& args)
Expand Down Expand Up @@ -179,8 +195,6 @@ int Runner::run(const PerfTestArgs& args)
}

// Create producer
typedef bsl::pair<bsl::shared_ptr<rmqa::Producer>, bsl::string>
ProducerRoutingKeyPair;
bsl::vector<ProducerRoutingKeyPair> producers;
{
bsl::vector<rmqt::QueueHandle>::const_iterator queues;
Expand Down Expand Up @@ -311,12 +325,10 @@ int Runner::run(const PerfTestArgs& args)

producerMessagesSent += 1;

if ((int)producerMessagesSent ==
if ((int)producerMessagesSent >=
args.producer.producerMessageCount) {
bsl::cout << producers.size()
<< " producers finished, exiting producers"
<< bsl::endl;
producers.clear();

finalizeProducers(producers);
}
}
}
Expand Down

0 comments on commit 20ca5fb

Please sign in to comment.