Function CSPThreadLockHandler::Lock()
Description:
It increments the thread lock count by one. If the attached thread lock object is locked by another thread, this member function waits until the object is unlocked.
 |
Prototype:
unsigned long Lock();
Arguments:
No arguments (void).
Return value:
It returns the current thread lock count.
Examples:
//Global scope declarations CSPThreadLock ThreadLock; int a = 0; int b = 0; ... ...
//Thread sensitive code { CSPThreadLockHandler Handler( ThreadLock );
Handler.Lock(); a += 2; b = b / a; // even on a "division by zero" exception, // the thread lock object is completely unlocked // during the destruction of object Handler.
Handler.Unlock(); // even if you omit the line above, // the thread lock object will be fully unlocked // during the destruction of object Handler. }
See also:
member functions Unlock(), TryLock()
|
|