mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-08-03 17:58:12 +02:00
Implemented read_slot_id
This commit is contained in:
@@ -15,6 +15,8 @@ ImageAssembler::ImageAssembler(const size_t n_modules) :
|
||||
for (size_t i=0; i<IA_N_SLOTS; i++) {
|
||||
free_slot(i);
|
||||
}
|
||||
|
||||
read_slot_id_ = 0;
|
||||
}
|
||||
|
||||
ImageAssembler::~ImageAssembler()
|
||||
@@ -65,17 +67,29 @@ void ImageAssembler::process(
|
||||
}
|
||||
}
|
||||
|
||||
buffer_status_[slot_id]--;
|
||||
auto previous_status = buffer_status_[slot_id].fetch_sub(1);
|
||||
|
||||
// 1 because fetch is done before subtraction.
|
||||
if (previous_status == 1) {
|
||||
write_slot_id_++;
|
||||
read_slot_id_ %= IA_N_SLOTS;
|
||||
}
|
||||
}
|
||||
|
||||
int ImageAssembler::get_full_slot()
|
||||
{
|
||||
if (buffer_status_[read_slot_id_] == 0) {
|
||||
return read_slot_id_;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ImageAssembler::free_slot(const int slot_id)
|
||||
{
|
||||
buffer_status_[slot_id] = n_modules_;
|
||||
|
||||
read_slot_id_ = (int)((read_slot_id_+1) % IA_N_SLOTS);
|
||||
}
|
||||
|
||||
ImageMetadataBlock* ImageAssembler::get_metadata_buffer(const int slot_id)
|
||||
|
||||
@@ -15,6 +15,8 @@ class ImageAssembler {
|
||||
ImageMetadataBlock* metadata_buffer_;
|
||||
std::atomic_int* buffer_status_;
|
||||
|
||||
int read_slot_id_;
|
||||
|
||||
public:
|
||||
ImageAssembler(const size_t n_modules);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user