Skip to content
Merged
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: 0 additions & 1 deletion runtime/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ cc_library(
deps = [
":engine_interface",
":engine_settings",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status",
Expand Down
13 changes: 10 additions & 3 deletions runtime/engine/engine_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include <cstddef>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#include "absl/container/flat_hash_map.h" // from @com_google_absl
#include "absl/functional/any_invocable.h" // from @com_google_absl
#include "absl/log/absl_log.h" // from @com_google_absl
#include "absl/status/status.h" // from @com_google_absl
Expand Down Expand Up @@ -209,10 +209,17 @@ class EngineFactory {
}},
}) {}

absl::flat_hash_map<EngineType, Creator> registry_;
// Use std::unordered_map instead of absl::flat_hash_map to avoid Windows
// build/linker issues across DLL boundaries (see cl/403158423 and
// b/508692203). std::unordered_map can also be faster when the number of
// elements is low.
std::unordered_map<EngineType, Creator> registry_;

// Map of preferred engine types for each backend. The first available
// (registered) engine type in the list will be selected by CreateDefault().
absl::flat_hash_map<Backend, std::vector<EngineType>> preferred_engines_;
// Use std::unordered_map for consistency with registry_ and to avoid similar
// Windows issues.
std::unordered_map<Backend, std::vector<EngineType>> preferred_engines_;
};

// Helper struct to register an engine type with the EngineFactory.
Expand Down
Loading