简体   繁体   中英

What's the functioning scope of an critical section locker in c++?

// 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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM