Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions form/root_storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(FORM_ROOT_STORAGE_SOURCES)
list(
APPEND FORM_ROOT_STORAGE_SOURCES
root_tfile.cpp
root_thread_safety.cpp
root_ttree_write_container.cpp
root_tbranch_read_container.cpp
root_tbranch_write_container.cpp
Expand Down
11 changes: 11 additions & 0 deletions form/root_storage/root_thread_safety.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (C) 2025 ...

#include "root_thread_safety.hpp"

#include <TROOT.h>

namespace form::detail::experimental {

void ensure_root_thread_safety() { ROOT::EnableThreadSafety(); }

} // namespace form::detail::experimental
13 changes: 13 additions & 0 deletions form/root_storage/root_thread_safety.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2025 ...

#ifndef FORM_ROOT_STORAGE_ROOT_THREAD_SAFETY_HPP
#define FORM_ROOT_STORAGE_ROOT_THREAD_SAFETY_HPP

namespace form::detail::experimental {

/// Enable ROOT thread safety.
void ensure_root_thread_safety();

} // namespace form::detail::experimental

#endif // FORM_ROOT_STORAGE_ROOT_THREAD_SAFETY_HPP
8 changes: 8 additions & 0 deletions form/storage/factories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "root_storage/root_tbranch_read_container.hpp"
#include "root_storage/root_tbranch_write_container.hpp"
#include "root_storage/root_tfile.hpp"
#include "root_storage/root_thread_safety.hpp"
#include "root_storage/root_ttree_write_container.hpp"
#endif

Expand All @@ -31,6 +32,13 @@ namespace form::detail::experimental {

using major = form::technology::major;

void ensure_backend_thread_safety()
{
#ifdef USE_ROOT_STORAGE
ensure_root_thread_safety();
#endif
}

std::shared_ptr<i_storage_file> create_file(form::technology::id tech,
std::string const& name,
char mode)
Expand Down
2 changes: 2 additions & 0 deletions form/storage/factories.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace form::detail::experimental {

void ensure_backend_thread_safety();

std::shared_ptr<i_storage_file> create_file(form::technology::id tech,
std::string const& name,
char mode);
Expand Down
1 change: 1 addition & 0 deletions form/storage/storage_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ namespace {
namespace form::detail::experimental {
std::unique_ptr<i_storage_reader> create_storage_reader()
{
ensure_backend_thread_safety();
return std::unique_ptr<i_storage_reader>(new storage_reader());
}
}
Expand Down
1 change: 1 addition & 0 deletions form/storage/storage_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace {
namespace form::detail::experimental {
std::unique_ptr<i_storage_writer> create_storage_writer()
{
ensure_backend_thread_safety();
return std::unique_ptr<i_storage_writer>(new storage_writer());
}
}
Expand Down
Loading