I suggest you not to use critical WinAPI partitions. You can get the same using std :: mutex . When you use it, you can also use the RAII idiom shell to automatically unlock the mutex ( std :: lock_guard ).
UPDATE: one difference between the critical sector and the mutex, which you can lock the critical section several times in one thread, but this is not true for simple std :: mutex. If you require recursive locking behavior, use std :: recursive_mutex std::lock_guard<std::recursive_mutex>
UPDATE 2: a detailed distinction between critical sections and mutexes is described here , performance comparison here .
Reasons: it is better to use the standard mechanism when you can. If you are using a platform-specific thing, wrap it around. Therefore, if you are afraid for performance, create a critical section class with lock / unlock methods (to meet the requirements of BasicLocakable ) and use std::lock_guard<MyCriticalSection> .
source share