Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Start/stop the txStats thread along with txThread
Browse files Browse the repository at this point in the history
This will avoid having an always running thread unnecessarily
  • Loading branch information
pstavirs committed Nov 23, 2023
1 parent 469e0b0 commit cf84060
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/pcaptransmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ PcapTransmitter::PcapTransmitter(
txStats_.setObjectName(QString("TxStats:%1").arg(device));
memset(&stats_, 0, sizeof(stats_));
txStats_.setTxThreadStats(&stats_);
txStats_.start(); // TODO: alongwith user transmit start

txThread_.setStats(&stats_);
connect(&txThread_, SIGNAL(finished()), SLOT(updateTxThreadStreamStats()));
}

PcapTransmitter::~PcapTransmitter()
{
txStats_.stop(); // TODO: alongwith user transmit stop
}

bool PcapTransmitter::setRateAccuracy(
Expand Down Expand Up @@ -126,12 +124,20 @@ void PcapTransmitter::useExternalStats(AbstractPort::PortStats *stats)

void PcapTransmitter::start()
{
// XXX: Start the stats thread before the tx thread, so no tx stats
// is missed
txStats_.start();
Q_ASSERT(txStats_.isRunning());
txThread_.start();
}

void PcapTransmitter::stop()
{
// XXX: Stop the tx thread before the stats thread, so no tx stats
// is missed
txThread_.stop();
Q_ASSERT(!txThread_.isRunning());
txStats_.stop();
}

bool PcapTransmitter::isRunning()
Expand Down

0 comments on commit cf84060

Please sign in to comment.