Ken Van Hoeylandt de46401d85
Loader refactored (#235)
- Moved all Loader functionality into Loader class
- Improvement for Dispatcher construction
- Dispatcher and DispatcherThread: you can now specify the timeout when calling `dispatch()`. Default timeout is max timeout.
2025-02-23 16:08:00 +01:00

34 lines
694 B
C++

#pragma once
#include "Dispatcher.h"
namespace tt {
/** Starts a Thread to process dispatched messages */
class DispatcherThread {
Dispatcher dispatcher;
std::unique_ptr<Thread> thread;
bool interruptThread = false;
public:
explicit DispatcherThread(const std::string& threadName, size_t threadStackSize = 4096);
~DispatcherThread();
/**
* Dispatch a message.
*/
void dispatch(Dispatcher::Function function, std::shared_ptr<void> context, TickType_t timeout = portMAX_DELAY);
/** Start the thread (blocking). */
void start();
/** Stop the thread (blocking). */
void stop();
/** Internal method */
void _threadMain();
};
}