diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-22 14:16:33 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-22 14:16:33 +1100 |
| commit | f9aec8b6906599296417af5414b1c72a3cf53e73 (patch) | |
| tree | 088fb6abe8cb1cf1d3a389572c5b6f577fa8e2e2 /src/lua/lua_thread.cpp | |
| parent | 4b2003c78a5e4270f384283f72d185cd4a40f30e (diff) | |
| download | tangara-fw-f9aec8b6906599296417af5414b1c72a3cf53e73.tar.gz | |
split the lua thread registry into its own files
Diffstat (limited to 'src/lua/lua_thread.cpp')
| -rw-r--r-- | src/lua/lua_thread.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/lua/lua_thread.cpp b/src/lua/lua_thread.cpp index 7d64e3c5..dd72e41d 100644 --- a/src/lua/lua_thread.cpp +++ b/src/lua/lua_thread.cpp @@ -184,51 +184,4 @@ auto CallProtected(lua_State* s, int nargs, int nresults) -> int { return ret; } -auto Registry::instance(system_fsm::ServiceLocator& s) -> Registry& { - static Registry sRegistry{s}; - return sRegistry; -} - -Registry::Registry(system_fsm::ServiceLocator& services) - : services_(services), bridge_(new Bridge(services)) {} - -auto Registry::uiThread() -> std::shared_ptr<LuaThread> { - if (!ui_thread_) { - ui_thread_ = newThread(); - bridge_->installLvgl(ui_thread_->state()); - } - return ui_thread_; -} - -auto Registry::newThread() -> std::shared_ptr<LuaThread> { - std::shared_ptr<LuaThread> thread{LuaThread::Start(services_)}; - bridge_->installBaseModules(thread->state()); - for (auto& module : modules_) { - bridge_->installPropertyModule(thread->state(), module.first, - module.second); - } - threads_.push_back(thread); - return thread; -} - -auto Registry::AddPropertyModule( - const std::string& name, - std::vector<std::pair<std::string, std::variant<LuaFunction, Property*>>> - properties) -> void { - modules_.push_back(std::make_pair(name, properties)); - - // Any live threads will need to be updated to include the new module. - auto it = threads_.begin(); - while (it != threads_.end()) { - auto thread = it->lock(); - if (!thread) { - // Thread has been destroyed; stop tracking it. - it = threads_.erase(it); - } else { - bridge_->installPropertyModule(thread->state(), name, properties); - it++; - } - } -} - } // namespace lua |
