Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/pqi/pqithreadstreamer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ int pqithreadstreamer::tick()

void pqithreadstreamer::threadTick()
{
static uint32_t recv_timeout = mTimeout;
static uint32_t sleep_period = mSleepPeriod;
uint32_t readbytes = 0;
uint32_t sentbytes = 0;
bool isactive = false;
Expand All @@ -95,7 +93,7 @@ void pqithreadstreamer::threadTick()
// Fill incoming queue
{
RsStackMutex stack(mThreadMutex);
readbytes = tick_recv(recv_timeout);
readbytes = tick_recv(mTimeout);
}

// Process incoming items, move them to relevant service queue or shortcut to fast service
Expand All @@ -117,22 +115,22 @@ void pqithreadstreamer::threadTick()
{
// Activity detected: switch to maximum reactivity immediately
// This ensure fast throughput for data bursts
recv_timeout = STREAMER_TIMEOUT_MIN;
sleep_period = STREAMER_SLEEP_MIN;
mTimeout = STREAMER_TIMEOUT_MIN;
mSleepPeriod = STREAMER_SLEEP_MIN;
}
else
{
// No activity: gradually increase the timeout and sleep to save CPU cycles
if (recv_timeout < STREAMER_TIMEOUT_MAX)
recv_timeout += STREAMER_TIMEOUT_DELTA;
if (sleep_period < STREAMER_SLEEP_MAX)
sleep_period += STREAMER_SLEEP_DELTA;
if (mTimeout < STREAMER_TIMEOUT_MAX)
mTimeout += STREAMER_TIMEOUT_DELTA;
if (mSleepPeriod < STREAMER_SLEEP_MAX)
mSleepPeriod += STREAMER_SLEEP_DELTA;
}

// RsDbg() << "PQISTREAMER pqithreadstreamer::threadTick() recv_timeout " << std::dec << recv_timeout / 1000 << " sleep_period " << sleep_period / 1000 << " readbytes " << readbytes << " sentbytes " << sentbytes;
// RsDbg() << "PQISTREAMER " << threadName() << " pqithreadstreamer::threadTick() mTimeout " << std::dec << mTimeout / 1000 << " mSleepPeriod " << mSleepPeriod / 1000 << " readbytes " << readbytes << " sentbytes " << sentbytes;

if (sleep_period > 0)
if (mSleepPeriod > 0)
{
rstime::rs_usleep(sleep_period);
rstime::rs_usleep(mSleepPeriod);
}
}
Loading