PreviewImage: remove mutex

This commit is contained in:
2024-05-23 22:58:52 +02:00
parent 500222bdcc
commit f85b87bfd2
10 changed files with 181 additions and 139 deletions

View File

@@ -51,12 +51,17 @@ void JFJochReceiverService::Start(const DiffractionExperiment &experiment, const
throw JFJochException(JFJochExceptionCategory::WrongDAQState, "Receiver not idle, cannot start");
try {
preview_image.Configure(experiment);
preview_image_indexed.Configure(experiment);
// Thanks to properties of unique_ptr, starting new measurement will call destructor of JFJochReceiver, which will
// ensure that everything was rolled back
receiver = std::make_unique<JFJochReceiver>(experiment, calibration,
aq_devices, image_pusher,
logger, nthreads, numa_policy,
spot_finding_settings,
preview_image,
preview_image_indexed,
buffer);
try {
// Don't want to stop
@@ -128,19 +133,17 @@ std::vector<AcquisitionDeviceNetConfig> JFJochReceiverService::GetNetworkConfig(
}
std::string JFJochReceiverService::GetTIFF(bool calibration) const {
std::unique_lock ul(state_mutex);
if (receiver)
return receiver->GetTIFF(calibration);
if (calibration)
return preview_image.GenerateTIFFDioptas();
else
return "";
return preview_image.GenerateTIFF();
}
std::string JFJochReceiverService::GetJPEG(const PreviewJPEGSettings &settings) const {
std::unique_lock ul(state_mutex);
if (receiver)
return receiver->GetJPEG(settings);
if (settings.show_indexed)
return preview_image_indexed.GenerateJPEG(settings);
else
return "";
return preview_image.GenerateJPEG(settings);
}
void JFJochReceiverService::LoadInternalGeneratorImage(const DiffractionExperiment &experiment,