ImageBuffer: Improved logic for slot management

This commit is contained in:
2026-02-28 21:22:58 +01:00
parent c92afa95fb
commit c897008d6e
14 changed files with 242 additions and 57 deletions
+21 -3
View File
@@ -7,7 +7,7 @@
#include "ThreadSafeFIFO.h"
ZeroCopyReturnValue::ZeroCopyReturnValue(void *in_ptr, ImageBuffer &in_ctrl, uint32_t in_handle)
: ptr(in_ptr), handle(in_handle), buf_ctrl(in_ctrl), image_number(-1), payload_size(0),
: ptr(in_ptr), payload_size(0), image_number(-1), buf_ctrl(in_ctrl), handle(in_handle),
indexed(false) {
}
@@ -27,8 +27,16 @@ void * ZeroCopyReturnValue::GetImage() const {
return ptr;
}
void ZeroCopyReturnValue::release() const {
buf_ctrl.ReleaseSlot(handle, image_number, payload_size, indexed);
void ZeroCopyReturnValue::release() {
if (status == ImageBufferEntryStatus::InPreparation)
ReadyToSend();
if (status == ImageBufferEntryStatus::Sending) {
buf_ctrl.ReleaseSlot(handle);
} else {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Trying to send image that is not in preparation");
}
}
int64_t ZeroCopyReturnValue::GetImageNumber() const {
@@ -46,3 +54,13 @@ bool ZeroCopyReturnValue::IsIndexed() const {
uint32_t ZeroCopyReturnValue::GetHandle() const {
return handle;
}
void ZeroCopyReturnValue::ReadyToSend() {
if (status == ImageBufferEntryStatus::InPreparation) {
buf_ctrl.ReadyToSend(handle, image_number, payload_size, indexed);
status = ImageBufferEntryStatus::Sending;
} else {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Trying to send image that is not in preparation");
}
}