mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-03 19:46:32 +00:00
CrashGenerationServer's state machine can be invoked from both the application
thread and thread pool threads. This CL serializes access to the FSM state. Handling of crash dump and client shutdown requests is still done asynchronously. Patch by Alex Pakhunov <alexeypa@chromium.org> BUG=132164 TEST=remoting_unittests.BreakpadWinDeathTest.* Review URL: https://breakpad.appspot.com/396002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@970 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
@@ -40,14 +40,31 @@ class AutoCriticalSection {
|
||||
public:
|
||||
// Creates a new instance with the given critical section object
|
||||
// and enters the critical section immediately.
|
||||
explicit AutoCriticalSection(CRITICAL_SECTION* cs) : cs_(cs) {
|
||||
explicit AutoCriticalSection(CRITICAL_SECTION* cs) : cs_(cs), taken_(false) {
|
||||
assert(cs_);
|
||||
EnterCriticalSection(cs_);
|
||||
Acquire();
|
||||
}
|
||||
|
||||
// Destructor: leaves the critical section.
|
||||
~AutoCriticalSection() {
|
||||
if (taken_) {
|
||||
Release();
|
||||
}
|
||||
}
|
||||
|
||||
// Enters the critical section. Recursive Acquire() calls are not allowed.
|
||||
void Acquire() {
|
||||
assert(!taken_);
|
||||
EnterCriticalSection(cs_);
|
||||
taken_ = true;
|
||||
}
|
||||
|
||||
// Leaves the critical section. The caller should not call Release() unless
|
||||
// the critical seciton has been entered already.
|
||||
void Release() {
|
||||
assert(taken_);
|
||||
LeaveCriticalSection(cs_);
|
||||
taken_ = false;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -56,6 +73,7 @@ class AutoCriticalSection {
|
||||
AutoCriticalSection& operator=(const AutoCriticalSection&);
|
||||
|
||||
CRITICAL_SECTION* cs_;
|
||||
bool taken_;
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
||||
Reference in New Issue
Block a user