Skip to content

Commit

Permalink
Merge pull request #188 from nlesc-recruit/update-markers
Browse files Browse the repository at this point in the history
Make markers more robust
  • Loading branch information
loostrum authored Nov 19, 2024
2 parents 4562cd9 + df6cedc commit 86531ad
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions host/src/PowerSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ void PowerSensor::waitForMarkers(int timeout) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
auto elapsed = std::chrono::high_resolution_clock::now() - tstart;
if (elapsed.count() > timeout) {
break;
// clear any remaining markers
while (!markers.empty()) {
markers.pop();
}
break;
}
}
}
Expand Down Expand Up @@ -448,8 +452,8 @@ void PowerSensor::stopIOThread() {
* @param dumpFileName
*/
void PowerSensor::dump(std::string dumpFileName) {
// if dumping should be stopped, first wait until all markers are written
if (dumpFileName.empty()) {
// if dumping to a new file or dumping should be stopped, first wait until all markers are written
if (dumpFile != nullptr || dumpFileName.empty()) {
waitForMarkers();
}

Expand Down

0 comments on commit 86531ad

Please sign in to comment.