Skip to content

Commit

Permalink
fix(BaseWriter): Timeout waiting for full frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristpinsm authored and andrerenard committed May 4, 2021
1 parent 58919a4 commit 6234c11
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/stages/BaseWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <functional> // for _Bind_helper<>::type, bind, function
#include <regex> // for match_results<>::_Base_type
#include <stdexcept> // for runtime_error, out_of_range
#include <time.h> // for timespec
#include <utility> // for pair
#include <vector> // for vector

Expand Down Expand Up @@ -95,19 +96,22 @@ void BaseWriter::main_thread() {

frameID frame_id(in_buf);

const timespec timeout = double_to_ts(acq_timeout);

while (!stop_thread) {

// Wait for the buffer to be filled with data
if (wait_for_full_frame(in_buf, unique_name.c_str(), frame_id) == nullptr) {
auto status = wait_for_full_frame_timeout(in_buf, unique_name.c_str(), frame_id, timeout);
if (status == 0) {
// Write frame
write_data(in_buf, frame_id);

// Mark the buffer and move on
mark_frame_empty(in_buf, unique_name.c_str(), frame_id++);
} else if (status == -1) {
break;
}

// Write frame
write_data(in_buf, frame_id);

// Mark the buffer and move on
mark_frame_empty(in_buf, unique_name.c_str(), frame_id++);

// Clean out any acquisitions that have been inactive long
close_old_acqs();
}
Expand Down

0 comments on commit 6234c11

Please sign in to comment.