mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed.
llvm-svn: 128008
This commit is contained in:
parent
58a4560569
commit
a462a53e0b
@ -63,6 +63,10 @@ public:
|
||||
/// thread which is in a protected context.
|
||||
static CrashRecoveryContext *GetCurrent();
|
||||
|
||||
/// \brief Return true if the current thread is recovering from a
|
||||
/// crash.
|
||||
static bool isRecoveringFromCrash();
|
||||
|
||||
/// \brief Execute the provide callback function (with the given arguments) in
|
||||
/// a protected context.
|
||||
///
|
||||
|
@ -57,11 +57,15 @@ public:
|
||||
static sys::Mutex gCrashRecoveryContexMutex;
|
||||
static bool gCrashRecoveryEnabled = false;
|
||||
|
||||
static sys::ThreadLocal<const CrashRecoveryContextCleanup>
|
||||
tlIsRecoveringFromCrash;
|
||||
|
||||
CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
|
||||
|
||||
CrashRecoveryContext::~CrashRecoveryContext() {
|
||||
// Reclaim registered resources.
|
||||
CrashRecoveryContextCleanup *i = head;
|
||||
tlIsRecoveringFromCrash.set(head);
|
||||
while (i) {
|
||||
CrashRecoveryContextCleanup *tmp = i;
|
||||
i = tmp->next;
|
||||
@ -69,11 +73,16 @@ CrashRecoveryContext::~CrashRecoveryContext() {
|
||||
tmp->recoverResources();
|
||||
delete tmp;
|
||||
}
|
||||
tlIsRecoveringFromCrash.erase();
|
||||
|
||||
CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
|
||||
delete CRCI;
|
||||
}
|
||||
|
||||
bool CrashRecoveryContext::isRecoveringFromCrash() {
|
||||
return tlIsRecoveringFromCrash.get() != 0;
|
||||
}
|
||||
|
||||
CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
|
||||
if (!gCrashRecoveryEnabled)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user