mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
- Create real drivers instead of wrapping M5Unified/M5GFX - Display HAL improvements (better default base class behaviour) - Fixed bug with LVGL statusbar service locking (would hang indefinitely waiting for mutex, causing WDT issues) - Fixes for `Critical.h` - Fixes and improvements for `Dispatcher` and `DispatcherThread`
46 lines
1002 B
C++
46 lines
1002 B
C++
#include "DispatcherThread.h"
|
|
|
|
namespace tt {
|
|
|
|
int32_t dispatcherThreadMain(void* context) {
|
|
auto* dispatcherThread = (DispatcherThread*)context;
|
|
dispatcherThread->_threadMain();
|
|
return 0;
|
|
}
|
|
|
|
DispatcherThread::DispatcherThread(const std::string& threadName, size_t threadStackSize) {
|
|
thread = std::make_unique<Thread>(
|
|
threadName,
|
|
threadStackSize,
|
|
dispatcherThreadMain,
|
|
this
|
|
);
|
|
}
|
|
|
|
DispatcherThread::~DispatcherThread() {
|
|
if (thread->getState() != Thread::StateStopped) {
|
|
stop();
|
|
}
|
|
}
|
|
|
|
void DispatcherThread::_threadMain() {
|
|
do {
|
|
dispatcher.consume(1000 / portTICK_PERIOD_MS);
|
|
} while (!interruptThread);
|
|
}
|
|
|
|
void DispatcherThread::dispatch(Callback callback, std::shared_ptr<void> context) {
|
|
dispatcher.dispatch(callback, std::move(context));
|
|
}
|
|
|
|
void DispatcherThread::start() {
|
|
interruptThread = false;
|
|
thread->start();
|
|
}
|
|
|
|
void DispatcherThread::stop() {
|
|
interruptThread = true;
|
|
thread->join();
|
|
}
|
|
|
|
} |