What's the functioning scope of an critical section locker in c++?
-
29-09-2019 - |
Question
// locks a critical section, and unlocks it automatically
// when the lock goes out of scope
CAutoLock(CCritSec * plock)
The above is from wxutil.h
, does it lock the access of different process , or just locks different threads in the same process?
Solution
Just across threads. From the doc of CAutoLock:
The CAutoLock constructor locks the critical section, ...
and CCritSec:
The CCritSec class provides a thread lock.
More explicitly, from the description of Critical Section Objects:
A critical section object provides synchronization similar to that provided by a mutex object, except that a critical section can be used only by the threads of a single process.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow