The threading.h header exposes a global mutex declaration macro, an exception-safe mutex locker, and the synchronized class mechanism.
The ConfigReader class is not protected, but that shouldn't be much of an issue except when it is to be re-read. That problem should be addressed sometime, or clients will just need to protect it themselves.
The messages, wire protocol implementations, and XML classes are unprotected. No more than 1 thread can access the same XML document at a time (reading is probably safe, but writing needs to be protected by the clien tcode). Same goes for messages and wire protocol classes.
// some global declarations LIBBAMBOO_STATIC_MUTEX(muxName); // some more global declarations
This allows us to add support for more threading mechanisms in the future. To lock a mutex, instantiate the BambooLib::threading::mutex_locker class locally. It locks the mutex on creation, and unlocks it when it goes out of scope, thus creating a critical section from the declaration of the mutex_locker through the end of the scope. The critical section can be locked and unlocked, but it starts out locked.
Note that mutex_locker and global mutexes are not recursive.
Example:
{
// some code
mutex_locker crit(mutex);
// some criticala code
} // critical section ends here
To have synchronization semantics, a class must inherit from BambooLib::threading::synchronized. This inheritance can be private or protected (in fact, this is the recommended procedure). synchronized declares a proteced inner class, synchronize, that locks the instance. Its usage is much like mutex_locker, except that it takes the instance as its constructor parameter rather than a mutex. It is also a recursive lock - the same thread can lock it more than once, provided that it unlocks it as many times as it locks it.
When writing synchronized methods, it is imperative to be careful to avoid deadlocks. Synchronized code in methods on class instance A cannot call synchronized code on class instance B (of the same or different classes, it doesn't matter) unless it is guaranteed that all synchronized code pertaining to B will call no further synchronized code for other instances (including A). This restriction is probably specified a tad too strictly, but you have to be really careful. If this guideline is followed, the code should be safe.
Since a synchronize object can be locked and unlocked, it is possible to have only parts of methods synchronized.
1.5.1