Multiple threads could be calling into DoLoadImage concurrently,
only one should be allowed to create the UtilityFunction.
Details
Diff Detail
- Build Status
Buildable 17975 Build 17975: arc lint + arc unit
Event Timeline
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1046–1047 | We should put the mutex, or better yet a std::once_flag, in the process as an instance variable. The utility function belongs to each process. |
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1046–1047 | I don't disagree, but it seemed a little overkill. Would you just put it as a public member? Or add a GetLoadImageUtilityFunctionOnceFlag() accessor? |
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1047 | Accessor would be fine. The other reason for putting this in the process is multi-threaded code that attempts to use this after the main thread has exited will crash as the static mutex might destruct itself. |
I heted the idea of hosting the once_flag in Process but using
it in PlatformPOSIX. I did a bigger refactoring where platforms
pass a factory lambda to the accessor and the thread-safe init
is done in the Process class itself using this lambda.
We should put the mutex, or better yet a std::once_flag, in the process as an instance variable. The utility function belongs to each process.