If you're already familiar with boost::threads, then you'll be very comfortable with Metrowerks::threads. The interface closely follows the boost library. There are some minor differences.
The biggest difference is that the library is part of EWL C++, and lives in namespace Metrowerks. The entire package can be accessed via <ewl_thread>. It is essentially a fairly thin C++ wrapper over a sub-set of Posix-threads. And there is also a "single thread" version where most of the code just does nothing. It is there to ease porting multithreaded code to a single threaded environment. But be aware that your multithreaded logic may or may not translate into a working single threaded application (especially if you deal with condition variables).
The threads library currently has these configuration flags:
| Flag | Effects |
|---|---|
| _EWL_SINGLE_THREAD | A do-nothing stand-in |
| _EWL_USE_PTHREADS | Poxsix-Threads |
| _EWL_USE_WINTHREADS | Windows threads |
EWL C++ will automatically configure itself based on how _EWL_THREADSAFE is set. However you can override the automatic configuration simply by setting it yourself in your prefix file or preprocesssor preference panel. You must recompile the C++ library to have the same setting.
You can now create a runtime check to make sure your EWL C++ is compiled with consistent settings:
#include <ewl_utility>
int main()
{
check(Metrowerks::ewl_settings());
}
This program will assert if it finds anything inconsistent between itself and the way EWL C++ was compiled.