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:
1 parent
0df7663286
commit
4907014e49
5 files changed
+19
-2
No files matched your search
@@ -324,6 +324,17 @@ size_t ImageBuffer::GetBufferSize() const {
|
|||||||
return buffer_size;
|
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 ImageBuffer::GetStatus() const {
|
||||||
ImageBufferStatus ret;
|
ImageBufferStatus ret;
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,5 +92,7 @@ public:
|
|||||||
void SaveStartMessage(const std::vector<uint8_t> &msg);
|
void SaveStartMessage(const std::vector<uint8_t> &msg);
|
||||||
void GetStartMessage(std::vector<uint8_t> &out_v);
|
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;
|
ImageBufferStatus GetStatus() const;
|
||||||
};
|
};
|
||||||
@@ -350,7 +350,7 @@ void JFJochReceiverFPGA::FrameTransformationThread(uint32_t threadid) {
|
|||||||
|
|
||||||
analyzer->Process(message, local_spot_finding_settings);
|
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_available = status.available_slots;
|
||||||
message.receiver_buf_in_preparation = status.preparation_slots;
|
message.receiver_buf_in_preparation = status.preparation_slots;
|
||||||
message.receiver_buf_in_sending = status.sending_slots;
|
message.receiver_buf_in_sending = status.sending_slots;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ ZeroCopyReturnValue *JFJochReceiverRugnuxStills::AnalysedImageSlot() {
|
|||||||
|
|
||||||
void JFJochReceiverRugnuxStills::SendAnalysedImage(DataMessage &message, const AzimuthalIntegrationProfile &profile) {
|
void JFJochReceiverRugnuxStills::SendAnalysedImage(DataMessage &message, const AzimuthalIntegrationProfile &profile) {
|
||||||
try {
|
try {
|
||||||
const auto status = image_buffer.GetStatus();
|
const auto status = image_buffer.GetSlotStatus();
|
||||||
message.receiver_buf_available = status.available_slots;
|
message.receiver_buf_available = status.available_slots;
|
||||||
message.receiver_buf_in_preparation = status.preparation_slots;
|
message.receiver_buf_in_preparation = status.preparation_slots;
|
||||||
message.receiver_buf_in_sending = status.sending_slots;
|
message.receiver_buf_in_sending = status.sending_slots;
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ TEST_CASE("ImageBuffer") {
|
|||||||
REQUIRE(buf_ctrl.GetStatus().preparation_slots == 2);
|
REQUIRE(buf_ctrl.GetStatus().preparation_slots == 2);
|
||||||
REQUIRE(buf_ctrl.GetStatus().sending_slots == 2);
|
REQUIRE(buf_ctrl.GetStatus().sending_slots == 2);
|
||||||
REQUIRE(buf_ctrl.GetStatus().available_slots == 0);
|
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();
|
ret2->ReadyToSend();
|
||||||
ret3->ReadyToSend();
|
ret3->ReadyToSend();
|
||||||
|
|||||||
Reference in new issue
Block a user