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.
This commit is contained in:
Ken Van Hoeylandt
2025-02-23 16:08:00 +01:00
committed by GitHub
parent bd2786b122
commit de46401d85
8 changed files with 203 additions and 190 deletions
@@ -24,10 +24,7 @@ public:
std::shared_ptr<const Bundle> _Nullable parameters;
LoaderMessageAppStart() = default;
LoaderMessageAppStart(LoaderMessageAppStart& other) :
id(other.id),
parameters(other.parameters) {}
LoaderMessageAppStart(LoaderMessageAppStart& other) = default;
LoaderMessageAppStart(const std::string& id, std::shared_ptr<const Bundle> parameters) :
id(id),
@@ -37,16 +34,22 @@ public:
~LoaderMessageAppStart() = default;
};
class LoaderMessageAppStop {
public:
std::string id;
LoaderMessageAppStop() = default;
LoaderMessageAppStop(LoaderMessageAppStop& other) = default;
LoaderMessageAppStop(const std::string& id) : id(id) {}
~LoaderMessageAppStop() = default;
};
// endregion LoaderMessage
struct Loader {
std::shared_ptr<PubSub> pubsubExternal = std::make_shared<PubSub>();
Mutex mutex = Mutex(Mutex::Type::Recursive);
std::stack<std::shared_ptr<app::AppInstance>> appStack;
/** The dispatcher thread needs a callstack large enough to accommodate all the dispatched methods.
* This includes full LVGL redraw via Gui::redraw()
*/
std::unique_ptr<DispatcherThread> dispatcherThread = std::make_unique<DispatcherThread>("loader_dispatcher", 6144); // Files app requires ~5k
};
} // namespace