class CHoge {
void f() {
GetCriticalSection()->Enter();
g();
GetCriticalSection()->Leave();
}
void g() {
GetCriticalSection()->Enter();
// 何か屋さんで何かを買う処理
GetCriticalSection()->Leave();
}
CCriticalSection* GetCriticalSection() { return& cs_; }
private:
CCriticalSection cs_;
};
|