WIP: Use call_once for dynamic loading ObjectFactoryBase::Initialize()#4227
WIP: Use call_once for dynamic loading ObjectFactoryBase::Initialize()#4227N-Dekker wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
Conversation
`ObjectFactoryBase::InitializeFactoryList()` has become unnecessary from pull request InsightSoftwareConsortium#3641 commit 48d0cb0 "STYLE: Remove pointer indirection from lists of ObjectFactoryBasePrivate"
`RegisterInternal()` is a private member function of ObjectFactoryBase. It is only called during the initialization of m_PimplGlobals.
af2067e to
8e44857
Compare
|
Please note: this is really still in an experimental state. I still need to figure out exactly how things work! (The other PR, #4225 is ready though, independent of the discussion on atomic vs mutex vs call_once) |
Removed `ObjectFactoryBasePrivate::m_Initialized`. Removed `RegisterInternal()` call from `ObjectFactoryBase::Initialize()`.
8e44857 to
2610540
Compare
|
A little off topic. Interesting what OpenGL factory is mentioned here :) It looks like the class was a long time ago copied from VTK, s. comment in vtkObjectFactory.cxx. |
Thanks for your input, @issakomi I'm now proposing to just remove RegisterInternal(), including the apparently VTK specific comment about "the OpenGL factory". Please check: |
|
I'm afraid I was mistaken when I was thinking that ITK/Modules/Core/Common/src/itkObjectFactoryBase.cxx Lines 223 to 227 in ecd7bda But in fact, it may be called more than once, on the very same ITK/Modules/Core/Common/src/itkObjectFactoryBase.cxx Lines 457 to 462 in ecd7bda So I guess we may need to reconsider using a mutex (PR #4226?)... at least if we think we have serious thread-safety problem here. |
|
Abandoned: this approach (using |
Removed
ObjectFactoryBasePrivate::m_Initialized. MovedRegisterInternal()call from
ObjectFactoryBase::Initialize()to the default-constructor ofObjectFactoryBasePrivate.Also cherry-picked the commit from pull request #4225, STYLE: Remove private ObjectFactoryBase member InitializeFactoryList(). (This PR is not meant to supersede PR #4225)