class GCriticalSection

Mutual exclusion class.

Public Methods

[more]void lock()
Locks a critical section.
[more]void unlock()
Unlocks a critical section object.


Documentation

Mutual exclusion class. Class GCriticalSection provides an efficient way to protect segment of codes (critical sections) which should not be simultaneously executed by two threads. Only one thread can own a critical section object at a given time. Function lock causes the current thread to own the critical section object (or wait as long as necessary). Function unlock is used to release the critical section object. Critical section in the code are easily protected by creating a critical section object, locking this object at beginning of the critical section code, and unlocking the object at the end of the critical section code. Class GCriticalSectionLock provides a convenient way to do this effectively.

Note. Both the copy constructor and the copy operator are declared as private members. It is therefore not possible to make multiple copies of instances of this class, as implied by the class semantic.

ovoid lock()
Locks a critical section. Only one thread can own a critical section at a given time. If the critical section is already owned by another thread, the thread waits until the critical section is released. Otherwise the locking counter is incremented and the current thread is given ownership of the critical section object.

ovoid unlock()
Unlocks a critical section object. If the critical section is owned by the current thread, the locking counter is decremented. The critical section is released when the counter reaches zero.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java