mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -63,6 +63,10 @@ public:
|
|||||||
/// thread which is in a protected context.
|
/// thread which is in a protected context.
|
||||||
static CrashRecoveryContext *GetCurrent();
|
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
|
/// \brief Execute the provide callback function (with the given arguments) in
|
||||||
/// a protected context.
|
/// a protected context.
|
||||||
///
|
///
|
||||||
|
@ -57,11 +57,15 @@ public:
|
|||||||
static sys::Mutex gCrashRecoveryContexMutex;
|
static sys::Mutex gCrashRecoveryContexMutex;
|
||||||
static bool gCrashRecoveryEnabled = false;
|
static bool gCrashRecoveryEnabled = false;
|
||||||
|
|
||||||
|
static sys::ThreadLocal<const CrashRecoveryContextCleanup>
|
||||||
|
tlIsRecoveringFromCrash;
|
||||||
|
|
||||||
CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
|
CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
|
||||||
|
|
||||||
CrashRecoveryContext::~CrashRecoveryContext() {
|
CrashRecoveryContext::~CrashRecoveryContext() {
|
||||||
// Reclaim registered resources.
|
// Reclaim registered resources.
|
||||||
CrashRecoveryContextCleanup *i = head;
|
CrashRecoveryContextCleanup *i = head;
|
||||||
|
tlIsRecoveringFromCrash.set(head);
|
||||||
while (i) {
|
while (i) {
|
||||||
CrashRecoveryContextCleanup *tmp = i;
|
CrashRecoveryContextCleanup *tmp = i;
|
||||||
i = tmp->next;
|
i = tmp->next;
|
||||||
@ -69,11 +73,16 @@ CrashRecoveryContext::~CrashRecoveryContext() {
|
|||||||
tmp->recoverResources();
|
tmp->recoverResources();
|
||||||
delete tmp;
|
delete tmp;
|
||||||
}
|
}
|
||||||
|
tlIsRecoveringFromCrash.erase();
|
||||||
|
|
||||||
CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
|
CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
|
||||||
delete CRCI;
|
delete CRCI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CrashRecoveryContext::isRecoveringFromCrash() {
|
||||||
|
return tlIsRecoveringFromCrash.get() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
|
CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
|
||||||
if (!gCrashRecoveryEnabled)
|
if (!gCrashRecoveryEnabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user