-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Improve thread-safety, reduce code duplication internal I/O factory registration #2819
Improve thread-safety, reduce code duplication internal I/O factory registration #2819
Conversation
Eases registering an internal factory exactly once, taking thread-safety into account by means of C++11 "magic statics".
Replaced the use of file-scope static `HasBeenRegistered` variables for conditional `RegisterOneFactory()` calls by the equivalent thread-safe `ObjectFactoryBase::RegisterInternalFactoryOnce<TFactory>()` calls. Using Notepad++ v8.1.4, Find in Files (Regular expression): Find what: if \(!.+IOFactoryHasBeenRegistered\)\r\n {\r\n .+IOFactoryHasBeenRegistered = true;\r\n (.+)::RegisterOneFactory\(\);\r\n } Replace with: ObjectFactoryBase::RegisterInternalFactoryOnce<$1>\(\);
4bf5b7c
to
fb47ffa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-Dekker cool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Improved thread-safety by replacing the use of file-scope static
HasBeenRegistered
variables with C++11 "magic statics", to implement internal I/O factory registration.Reduced code duplication by adding a helper member function template,
ObjectFactoryBase::RegisterInternalFactoryOnce<TFactory>()
.