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
DD Generic Singleton Pattern #23147
DD Generic Singleton Pattern #23147
Conversation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-23147/4564 |
A new Pull Request was created by @ianna (Ianna Osborne) for master. It involves the following packages: DetectorDescription/DDCMS @cmsbuild, @civanch, @Dr15Jones, @ianna, @mdhildreth can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
The tests are being triggered in jenkins. |
I believe a better way is to use a static template<typename T>
T* getInstance() {
static std::unique_ptr<T> s_instance{ std::make_unique<T>() };
return s_instance.get();
} This avoids the problem of having to declare the I would then change your class to hold the pointer, thereby avoiding the slight overhead of calling DDSingleton() : m_instance(getInstance()) {}
...
T* m_instance; |
@Dr15Jones - Thanks for looking into this! I just fancied using lambda expressions and the C++11 thread safety guarantee for function-local statics. I'll implement your suggestion and run the comparison tests. |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-23147/4578 |
Pull request #23147 was updated. @cmsbuild, @civanch, @Dr15Jones, @ianna, @mdhildreth can you please check and sign again. |
please test |
The tests are being triggered in jenkins. |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
Note, test1 uses getInstance():