Skip to content

Commit

Permalink
do not allow too many frames in q
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 29, 2024
1 parent fbbc301 commit 0a6ebe9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/mclient/evbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,6 @@ int EventBuilder_Loop(EventBuilder* eb) {
if (storage_manager.GetNumberOfEntries() == 0) {
storage_manager.millisSinceEpochForSpeedCalculation = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}

if (storage_manager.GetNumberOfFramesInQueue() > 10000) {
cout << "WARNING: Too many frames in processing queue, stopping main thread to catch up" << endl;
while (storage_manager.GetNumberOfFramesInQueue() > 1000) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
cout << "Resuming main thread" << endl;
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/root/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ void StorageManager::AddFrame(const vector<unsigned short>& frame) {
frames.push(frame);
frames_count++;

// pop oldest frames if we have too many
while (frames.size() > 100000) {
frames.pop();
constexpr size_t max_frames = 100000;

if (frames.size() >= max_frames) {
throw std::runtime_error("Too many frames in queue");
}
}

Expand Down

0 comments on commit 0a6ebe9

Please sign in to comment.