Heap Debugging and Thread Disable

This commit is contained in:
Thomas Göttgens 2022-12-29 22:42:05 +01:00
parent 4e4a74379e
commit a8f93d5f47
2 changed files with 16 additions and 0 deletions

View File

@ -74,8 +74,16 @@ bool OSThread::shouldRun(unsigned long time)
void OSThread::run()
{
#ifdef DEBUG_HEAP
auto heap = ESP.getFreeHeap();
#endif
currentThread = this;
auto newDelay = runOnce();
#ifdef DEBUG_HEAP
auto newHeap = ESP.getFreeHeap();
if (newHeap < heap)
DEBUG_MSG("Thread %s leaked heap %d -> %d (%d)\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
#endif
runned();
@ -85,6 +93,12 @@ void OSThread::run()
currentThread = NULL;
}
void OSThread::disable() {
enabled = false;
setInterval(INT32_MAX);
}
/**
* This flag is set **only** when setup() starts, to provide a way for us to check for sloppy static constructor calls.
* Call assertIsSetup() to force a crash if someone tries to create an instance too early.

View File

@ -53,6 +53,8 @@ class OSThread : public Thread
static void setup();
void disable();
/**
* Wait a specified number msecs starting from the current time (rather than the last time we were run)
*/