Made assets::data_stores thread safe.
This commit is contained in:
@@ -72,6 +72,35 @@ namespace assets::language
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
std::error_code assets::glsl_parser::prefetch(
|
||||
path_id_lookups&
|
||||
) {
|
||||
// Nothing to prefetch
|
||||
return {};
|
||||
}
|
||||
|
||||
std::error_code assets::glsl_parser::load(
|
||||
const path_id_lookups& lookups,
|
||||
shader_source_store& store,
|
||||
bool
|
||||
) {
|
||||
m_path_buffer.clear();
|
||||
lookups.shader_sources.by_extension(".glsl", m_path_buffer);
|
||||
|
||||
auto store_mutex = std::mutex{};
|
||||
|
||||
std::for_each(
|
||||
std::execution::parallel_unsequenced_policy{},
|
||||
m_path_buffer.begin(),
|
||||
m_path_buffer.end(),
|
||||
parser_context{ store, store_mutex }
|
||||
);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
assets::glsl_parser::parser_context::parser_context(
|
||||
store_type& m_store,
|
||||
std::mutex& m_store_mutex
|
||||
@@ -115,7 +144,7 @@ void assets::glsl_parser::parser_context::operator()(lookup_type::const_pointer
|
||||
|
||||
{
|
||||
auto lock = std::lock_guard{ *m_store_mutex };
|
||||
m_store->add(id, m_buffer);
|
||||
m_store->insert(id, m_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,35 +351,6 @@ std::error_code assets::glsl_parser::read_file(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::error_code assets::glsl_parser::prefetch(
|
||||
path_id_lookups&
|
||||
) {
|
||||
// Nothing to prefetch
|
||||
return {};
|
||||
}
|
||||
|
||||
std::error_code assets::glsl_parser::load(
|
||||
const path_id_lookups& lookups,
|
||||
shader_source_store& store,
|
||||
bool
|
||||
) {
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
m_path_buffer.clear();
|
||||
lookups.shader_sources.by_extension(".glsl", m_path_buffer);
|
||||
|
||||
auto store_mutex = std::mutex{};
|
||||
|
||||
std::for_each(
|
||||
std::execution::parallel_unsequenced_policy{},
|
||||
m_path_buffer.begin(),
|
||||
m_path_buffer.end(),
|
||||
parser_context{ store, store_mutex }
|
||||
);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool assets::glsl_parser::parse_geometry_declaration(
|
||||
const std::span<const std::string_view> values,
|
||||
model_geometry::types& geometry_type
|
||||
|
||||
Reference in New Issue
Block a user