/// 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.
///
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;
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;