Each reflected class has a mutex instance variable and each reflected class has a global mutex object associated to it. The type of that mutex object is user configurable. The instance variable will be used to lock write access to instance variables and the global mutex will be used to lock write access to class (static member-) variables.
Any type that is default constructible can be used as mutex-type. Any type that is constructible from an instance of the mutex type qualifies as locktype. (Allthough this alone won't help much to avoid race conditions in a multithreaded application)
Mutex and locktype can be configured in 2 flavours: one for singlethreaded applications and one for multithreaded applications. According to that, the kind of threading model is a typedef in the namespace userconfig (either: SingleThreadingModelTag or: MultiThreadingModelTag). Switching that typedef from SingleThreadingModelTag to MultiThreadingModelTag and supplying appropriate definitions for:
template<class ReflectedClass> struct MultiThreadingMutexType { typedef refl::EmptyMutex type; }; template<class ReflectedClass> struct MultiThreadingLockType { typedef refl::EmptyLock type; };
(and recompiling the whole world) injects an appropriate mutex lock in each set- function of a reflected member variable and in each traversion of non-const reflected classes. For that an instance of the LockType must be constructible with an instance of the MutexType).
Last revised: September 13, 2004 | Copyright © 2004 Arne Adams |