CSingleLock doubt
-
Hi, I am working on Threading and am using CSingleLock to control access to shared resource. I have a doubt..must the CCritical section be member of the class or can it be local to the function? 1) void foo() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } void foo1() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } 2) CCriticalSection m_CritSection; void foo() { CSingleLock singleLock(&m_CritSection); }void foo1() { CSingleLock singleLock(&m_CritSection); } Are both the baove approaches correct? Please give me your inputs on this? Thanks
-
Hi, I am working on Threading and am using CSingleLock to control access to shared resource. I have a doubt..must the CCritical section be member of the class or can it be local to the function? 1) void foo() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } void foo1() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } 2) CCriticalSection m_CritSection; void foo() { CSingleLock singleLock(&m_CritSection); }void foo1() { CSingleLock singleLock(&m_CritSection); } Are both the baove approaches correct? Please give me your inputs on this? Thanks
-
Hi, I am working on Threading and am using CSingleLock to control access to shared resource. I have a doubt..must the CCritical section be member of the class or can it be local to the function? 1) void foo() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } void foo1() { CCriticalSection CritSection; CSingleLock singleLock(&CritSection); } 2) CCriticalSection m_CritSection; void foo() { CSingleLock singleLock(&m_CritSection); }void foo1() { CSingleLock singleLock(&m_CritSection); } Are both the baove approaches correct? Please give me your inputs on this? Thanks
The
CCriticalSection
object must be a member of the class. Both locks must operate on the same object.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"