Implement a function that locks and unlocks a C++11 mutex
BRL-CAD implements support for running in parallel on computers with multiple CPUs and multiple cores. To support parallel data access, you generally need a mutex / semaphore construct that locks and unlocks access to data, causing threads to wait when it's in a locked state. C++11 recently introduced standard mutexes:
This task involves implementing the necessary logic to lock and unlock a mutex in bu_semaphore_acquire() and bu_semaphore_release() using std::mutex.
This requires a minor source code modification to bu_semaphore_aquire() and bu_semaphore_release():
- src/libbu/semaphore.c
You may optionally want to add/modify these:
- src/libbu/semaphore_cpp11mutex.cpp
- src/libbu/CMakelists.txt
You can put your implementation into a .cpp file or add your own new file and call a function from semaphore.c, whatever is easiest. You can toggle usage of your implementation in semaphore.c on whether HAVE_THREAD_LOCAL is defined. Be sure to run "ctest -R bu_semaphore" when you think you have it working to test your change. Be sure the tests are calling your code and get them to pass.
SUBMIT a patch file with your changes. You'll need to "svn add src/libbu/semaphore_cpp11mutex.cpp" (or however you name it) if you add a new file. See https://brlcad.org/wiki/Patches