struct CrashWatchdogTimingsValues
{ /// delays to take various actions in 1/4 of a second increments. int mnDisableEntries; intconst mnAbortAfter;
};
/** *Agenericclassfordetectingifagivencrashoralock-upcamefromaspecific *areaofcode(suchasOpenGL). *Usethishelpertotrackthat. *Theclassisatemplatesothattherecanbemultipleinstancesofstaticvariables.
*/ template <typename Dummy> class CrashZone
{ // gnEnterCount and gnLeaveCount are accessed both from multiple threads (cf. // WatchdogThread::execute; so need to be of atomic type) and from signal handlers (cf. // VCLExceptionSignal_impl; so need to be of lock-free atomic type). sig_atomic_t is chosen as // the underlying type under the assumption that it is most likely to lead to an atomic type // that is actually lock-free. However, gnEnterCount and gnLeaveCount are both monotonically // increasing, so will eventually overflow, so the underlying type better be unsigned, which // sig_atomic_t is not guaranteed to be: #if !defined ARM32 || (defined ARM32 && defined __ARM_PCS_VFP) using AtomicCounter = std::atomic<std::make_unsigned_t<std::sig_atomic_t>>;
static_assert(AtomicCounter::is_always_lock_free); #else using AtomicCounter = volatile std::make_unsigned_t<std::sig_atomic_t>; #endif
/// how many times have we entered a zone staticinline AtomicCounter gnEnterCount = 0; /// how many times have we left a new zone staticinline AtomicCounter gnLeaveCount = 0;
public:
CrashZone() { enter(); }
~CrashZone() { leave(); } staticbool isInZone() { return gnEnterCount != gnLeaveCount; } staticconst AtomicCounter& enterCount() { return gnEnterCount; } #ifdefined ARM32 && !defined __ARM_PCS_VFP && defined __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-volatile" #endif // prefer creating instances to manually calling enter()/leave() staticvoid enter() { gnEnterCount++; } staticvoid leave() { gnLeaveCount++; } #ifdefined ARM32 && !defined __ARM_PCS_VFP && defined __clang__ #pragma clang diagnostic pop #endif // these should be implemented for each specific zone if needed // static void hardDisable(); // static const CrashWatchdogTimingsValues& getCrashWatchdogTimingsValues(); // static void checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues); // static const char* name();
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.