Skip to content

Commit

Permalink
frame queue usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 29, 2024
1 parent cf9f57b commit da448b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/root/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ void StorageManager::AddFrame(const vector<unsigned short>& frame) {
frames.push(frame);
frames_count++;

constexpr size_t max_frames = 100000;

if (frames.size() >= max_frames) {
throw std::runtime_error("Too many frames in queue");
}
Expand All @@ -307,6 +305,10 @@ unsigned int StorageManager::GetNumberOfFramesInQueue() {
return frames.size();
}

double StorageManager::GetQueueUsage() {
return GetNumberOfFramesInQueue() / (double) max_frames;
}

std::pair<unsigned short, std::array<unsigned short, MAX_POINTS>> Event::get_signal_id_data_pair(size_t index) const {
unsigned short channel = signal_ids[index];
std::array<unsigned short, MAX_POINTS> data{};
Expand Down
2 changes: 2 additions & 0 deletions src/root/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class StorageManager {
void AddFrame(const std::vector<unsigned short>& frame);
std::vector<unsigned short> PopFrame();
unsigned int GetNumberOfFramesInQueue();
double GetQueueUsage();
unsigned int GetNumberOfFramesInserted() const;

private:
Expand All @@ -125,6 +126,7 @@ class StorageManager {
std::queue<std::vector<unsigned short>> frames;
std::atomic<unsigned long long> frames_count = 0;
std::mutex frames_mutex;
const size_t max_frames = 500000; // this should be about 2GB when full (depends on frame size)
};

} // namespace feminos_daq_storage
Expand Down

0 comments on commit da448b6

Please sign in to comment.