
Eames, Andrew <andrew <at> cognex.com> writes:
I've been continuing my quest to try and use Boost for my DSP and its C++ compiler. I've been looking at Boost.Thread and it seems that it relies on one of a fixed few threading libraries to exist. I have my own native implementation of mutexes etc. and it doesn't seem like there is any easy way to plug it in without editing a lot of the boost source. Is this an issue that has been raised before?
As Howard and Phil have posted, there is some scope for user-defined mutexes and locks (in particular) in the new boost trunk version (in order to match the new proposed standard library interface). However, fundamentally the code is tied to specific OS thread libraries --- you need to know how to launch a thread, how to allocate thread-local data, and how to implement mutexes and condition variables. e.g. boost::condition_variable_any will work with a user-defined mutex or lock, but it needs a platform-specific condition variable implementation internally. The code is split by platform, so you can add a new platform by detecting it in boost/thread/detail/platform.hpp, and putting the headers in boost/thread/<your-platform>. You then also need to modify the compiled lib: put new stuff in libs/thread/src/<your-platform> and modify the Jamfile to select your new code on that platform. It's not a trivial amount of work, but boost::thread doesn't have a "platform abstraction layer": it IS the platform abstraction layer. Anthony