ImageBuffer::GetSlotStatus: the slot counters without scanning the buffer, for every image

JFJochReceiverFPGA and JFJochReceiverRugnuxStills read three slot counters for each image through
GetStatus, which walks every slot under the buffer mutex, lists the image numbers and sorts them. With a
buffer sized for 2 kHz (thousands of slots) that is about a core of CPU and time on the mutex every
other buffer user needs. GetSlotStatus returns only the counters; GetStatus stays for the HTTP status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-08 07:49:07 +01:00
1 parent 0df7663286
commit 4907014e49
5 files changed
+19 -2

No files matched your search

+11
View File
@@ -324,6 +324,17 @@ size_t ImageBuffer::GetBufferSize() const {
return buffer_size;
}
ImageBufferStatus ImageBuffer::GetSlotStatus() const {
ImageBufferStatus ret{};
std::unique_lock ul(m);
ret.total_slots = slot_count;
ret.available_slots = slot_count - slots_sending - slots_preparation;
ret.preparation_slots = slots_preparation;
ret.sending_slots = slots_sending;
ret.current_counter = counter;
return ret;
}
ImageBufferStatus ImageBuffer::GetStatus() const {
ImageBufferStatus ret;
{
+2
View File
@@ -92,5 +92,7 @@ public:
void SaveStartMessage(const std::vector<uint8_t> &msg);
void GetStartMessage(std::vector<uint8_t> &out_v);
// Only the slot counters, no image list: cheap enough to call for every image
ImageBufferStatus GetSlotStatus() const;
ImageBufferStatus GetStatus() const;
};
+1 -1
View File
@@ -350,7 +350,7 @@ void JFJochReceiverFPGA::FrameTransformationThread(uint32_t threadid) {
analyzer->Process(message, local_spot_finding_settings);
auto status = image_buffer.GetStatus();
auto status = image_buffer.GetSlotStatus();
message.receiver_buf_available = status.available_slots;
message.receiver_buf_in_preparation = status.preparation_slots;
message.receiver_buf_in_sending = status.sending_slots;
+1 -1
View File
@@ -152,7 +152,7 @@ ZeroCopyReturnValue *JFJochReceiverRugnuxStills::AnalysedImageSlot() {
void JFJochReceiverRugnuxStills::SendAnalysedImage(DataMessage &message, const AzimuthalIntegrationProfile &profile) {
try {
const auto status = image_buffer.GetStatus();
const auto status = image_buffer.GetSlotStatus();
message.receiver_buf_available = status.available_slots;
message.receiver_buf_in_preparation = status.preparation_slots;
message.receiver_buf_in_sending = status.sending_slots;
+4
View File
@@ -49,6 +49,10 @@ TEST_CASE("ImageBuffer") {
REQUIRE(buf_ctrl.GetStatus().preparation_slots == 2);
REQUIRE(buf_ctrl.GetStatus().sending_slots == 2);
REQUIRE(buf_ctrl.GetStatus().available_slots == 0);
REQUIRE(buf_ctrl.GetSlotStatus().total_slots == 4);
REQUIRE(buf_ctrl.GetSlotStatus().preparation_slots == 2);
REQUIRE(buf_ctrl.GetSlotStatus().sending_slots == 2);
REQUIRE(buf_ctrl.GetSlotStatus().available_slots == 0);
ret2->ReadyToSend();
ret3->ReadyToSend();