HDF5: Minor fixes to supress errors and use common mutex for reading and writing
This commit is contained in:
@@ -98,7 +98,7 @@ std::string dataset_name(const std::string& path) {
|
||||
}
|
||||
|
||||
void JFJochHDF5Reader::ReadFile(const std::string& filename) {
|
||||
std::unique_lock ul(file_mutex);
|
||||
std::unique_lock ul(hdf5_mutex);
|
||||
try {
|
||||
auto dataset = std::make_shared<JFJochReaderDataset>();
|
||||
master_file = std::make_unique<HDF5ReadOnlyFile>(filename);
|
||||
@@ -448,7 +448,7 @@ void JFJochHDF5Reader::ReadFile(const std::string& filename) {
|
||||
}
|
||||
|
||||
uint64_t JFJochHDF5Reader::GetNumberOfImages() const {
|
||||
std::unique_lock ul(file_mutex);
|
||||
std::unique_lock ul(hdf5_mutex);
|
||||
return number_of_images;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ bool JFJochHDF5Reader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
std::vector<uint8_t> &buffer,
|
||||
int64_t image_number,
|
||||
bool update_dataset) {
|
||||
std::unique_lock ul(file_mutex);
|
||||
std::unique_lock ul(hdf5_mutex);
|
||||
|
||||
if (!dataset)
|
||||
return {};
|
||||
@@ -709,7 +709,7 @@ bool JFJochHDF5Reader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
}
|
||||
|
||||
void JFJochHDF5Reader::Close() {
|
||||
std::unique_lock ul(file_mutex);
|
||||
std::unique_lock ul(hdf5_mutex);
|
||||
master_file = {};
|
||||
number_of_images = 0;
|
||||
legacy_format_files.clear();
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "../writer/HDF5Objects.h"
|
||||
|
||||
class JFJochHDF5Reader : public JFJochReader {
|
||||
mutable std::mutex file_mutex;
|
||||
std::unique_ptr<HDF5ReadOnlyFile> master_file;
|
||||
|
||||
std::vector<std::string> legacy_format_files;
|
||||
|
||||
@@ -869,7 +869,10 @@ std::string HDF5Object::GetString(const std::string &name, const std::string &de
|
||||
}
|
||||
|
||||
bool HDF5Object::Exists(const std::string &name) const {
|
||||
return H5Lexists(GetID(), name.c_str(), H5P_DEFAULT) > 0;
|
||||
H5E_BEGIN_TRY {
|
||||
return H5Lexists(GetID(), name.c_str(), H5P_DEFAULT) > 0;
|
||||
} H5E_END_TRY;
|
||||
return false;
|
||||
}
|
||||
|
||||
herr_t func(hid_t group, const char *name, const H5L_info2_t *info, void *op_data) {
|
||||
|
||||
Reference in New Issue
Block a user