Skip to content
Open
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
24 changes: 18 additions & 6 deletions rdkperf/rdk_perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <ratio>
#include <chrono>
#include <condition_variable>
#include <atomic>

#include "rdk_perf_logging.h"
#include "rdk_perf_scopedlock.h"
Expand Down Expand Up @@ -110,7 +111,7 @@ class TimerCallback {

void StopTask() {
LOG(eWarning, "Stoping Timer Task\n");
m_bContinue = false;
m_bContinue.store(false);
Signal(EXIT_LOOP);
return;
};
Expand Down Expand Up @@ -141,26 +142,37 @@ class TimerCallback {
}

void Task() {
m_bContinue = true;
LOG(eWarning, "Task Started\n");
while(m_bContinue == true) {

{
std::unique_lock<std::mutex> lck(m_mtx);
if (m_current_state == EXIT_LOOP) {
LOG(eWarning, " Early StopTask detected. Exiting loop before start.\n");
return;
}
m_bContinue.store(true);
}

LOG(eWarning, "Task Starting\n");
while(m_bContinue.load() == true) {
if(!Loop()) {
LOG(eWarning, "Timer loop signaled for Exit..\n");
m_bContinue = false;
m_bContinue.store(false);
break;
}
LOG(eTrace, "Task sleeping %d seconds\n", TIMER_INTERVAL_SECONDS);
SignalResult result = Wait(TIMER_INTERVAL_SECONDS);
if(result == EXIT_LOOP) {
LOG(eWarning, "Exit task loop has been signaled\n");
m_bContinue.store(false);
break;
}
}
LOG(eWarning, "Task Completed\n");
return;
};
private:
void* m_Context;
bool m_bContinue;
std::atomic<bool> m_bContinue;
uint32_t m_nDelay;
uint32_t m_nCount;
// Timeout, signaling
Expand Down
Loading