So as a philosophy, ITK has usually had a wrapper around system level things to enable more portable code and isolation ITK from changes and system differences. Therefore, perhaps we should just write a different back end to these ITK classes which is C++11 based.
TBB also has mutex’s and conditional variables, is it better to stick with one treading API then mix them?
I was looking at itk::AtomicInt vs std::atomic it. We are not very consistent in which one we are using. We should stabbing consistency convention for using a C++11 or system level or itk level wrapper for these types of things.
Here is a comparable change done to itk::AtomicInt:
But we have the fooling occurrences of std::atomic:
Particular of concert is the Migration Guide. Which do we recommend using? While there is the flexibility in remote modules, we should be consistent and clear especially in the Core group.
itk::AtomicInt and itk::MutexLock had a lot of sense before C++11. Now they are just a duplication of standard library’s functionality, and therefore make no sense. I intend to rewrite itk::Mutex and friends to be wrappers for std::mutex etc. But we should also deprecate them, along with itk::AtomicInt and any other system abstractions which were needed in ITK before C++11.
At one time, there was a greater need for wrapping standard library functionality since it was not implemented or buggy across compilers. I do not think we need wrappers if the standard library implementations are available across platforms and toolchains.
We could mark itk::AtomicInt as deprecated and use std::atomic everwhere. At this point std::atomic has successfully proven itself as a cross-platform implementation for itk::AtomicInt.
Then the who constraints mostly could be replaced with static_assert and type traits. The old implementation is full of work arounds with old compilers and the compilation errors are not as clear.
I finally got around to this again. The latest code is here.
It looks like ITK’s Mutex and friends have an incompatible API with respect to std::mutex and friends. itk::MutexLock is recursive, whereas std::mutex is not. There is std::recursive_mutex, but std::condition_variable works only with plain std::mutex. So I don’t think we can re-implement ITK mutex infrastructure to be simple wrappers for std stuff. The problem is this public function. Whatever it returns needs to be usable by itk::ConditionVariable.
Now I think it is best if we move all the classes which duplicate functionality in C++11 standard library into a compatibility module. Should we create V4_Compatibility module or something similarly named, or put it in Deprecated?
I think these classes should be moved to ITKDeprecated. This will avoid confusion on their valid use and status. The transition is not difficult and is well-documented in the migration guide.
It depends on the compatibility requirements of your project.
If your ITK 4.13 code/project already depends or required C++11 then I would embrace those features in your project.
If however you are writing an ITK remote module or want your code/project to be fully compatible with all ITKv4 compilers then you would need to still use ITKv4 C++03 style and headers.