Good C++: Critical Section
friend class Lock;
This is how you encapsulate the critical section. This class should be part of your library. The correctness of resource management in this class is pretty obvious to a C++ programmer. Itís a no-brainer.