Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not rely on static variable initialization order in the backend registrar. #3

Merged
merged 1 commit into from
Feb 8, 2019

Conversation

selitvin
Copy link
Collaborator

@selitvin selitvin commented Feb 6, 2019

No description provided.

{
registered_backends_by_name = new std::unordered_map<std::string, BackendFactoryFunction>();
registered_backends_by_type = new std::unordered_map<std::string, BackendFactoryFunction>();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also do this in get_backend_for_type and get_backend_by_name just to be safe.

Maybe move these 4 lines into a separate function called initialize_registered_backends_if_needed or something and call it from all 3 places.

Also, as you said, making this initialization threadsafe is probably a good idea

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We could also just do a null check in the other two functions)

@VivekPanyam
Copy link
Collaborator

LGTM!

@VivekPanyam VivekPanyam merged commit f4071f3 into uber:master Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants