Various improvements (#264)
- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread` - Rename `SystemEvent`-related functions - WiFi: fix auto-connect when WiFi disconnects from bad signal - WiFi: fix auto-connect when WiFi fails to auto-connect - WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
This commit is contained in:
committed by
GitHub
parent
d72852a6e2
commit
3f1bfee3f5
@@ -2,18 +2,13 @@
|
||||
|
||||
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
|
||||
[this]() {
|
||||
return threadMain();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +18,7 @@ DispatcherThread::~DispatcherThread() {
|
||||
}
|
||||
}
|
||||
|
||||
void DispatcherThread::_threadMain() {
|
||||
int32_t DispatcherThread::threadMain() {
|
||||
do {
|
||||
/**
|
||||
* If this value is too high (e.g. 1 second) then the dispatcher destroys too slowly when the simulator exits.
|
||||
@@ -31,10 +26,12 @@ void DispatcherThread::_threadMain() {
|
||||
*/
|
||||
dispatcher.consume(100 / portTICK_PERIOD_MS);
|
||||
} while (!interruptThread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DispatcherThread::dispatch(Dispatcher::Function function, std::shared_ptr<void> context, TickType_t timeout) {
|
||||
dispatcher.dispatch(function, std::move(context), timeout);
|
||||
void DispatcherThread::dispatch(Dispatcher::Function function, TickType_t timeout) {
|
||||
dispatcher.dispatch(function, timeout);
|
||||
}
|
||||
|
||||
void DispatcherThread::start() {
|
||||
|
||||
Reference in New Issue
Block a user