mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-22 16:32:40 +00:00
fix: snapmakerprinteragent use moonraker's lifecycle-owned command worker
This commit is contained in:
@@ -136,6 +136,10 @@ protected:
|
||||
|
||||
virtual void on_status_loop_tick(const std::string& dev_id) {}
|
||||
|
||||
// Queue work that may use agent state. The command worker is joined during
|
||||
// destruction, so queued commands cannot outlive the agent.
|
||||
void enqueue_command(std::function<void()> fn);
|
||||
|
||||
private:
|
||||
int handle_request(const std::string& dev_id, const std::string& json_str);
|
||||
int send_version_info(const std::string& dev_id);
|
||||
@@ -254,7 +258,6 @@ private:
|
||||
std::thread connect_thread;
|
||||
mutable std::recursive_mutex connect_mutex;
|
||||
|
||||
void enqueue_command(std::function<void()> fn);
|
||||
void run_command_worker();
|
||||
std::thread cmd_thread;
|
||||
std::deque<std::function<void()>> cmd_queue;
|
||||
|
||||
@@ -82,10 +82,10 @@ SnapmakerPrinterAgent::SnapmakerPrinterAgent(std::string log_dir) : MoonrakerPri
|
||||
|
||||
void SnapmakerPrinterAgent::start_camera_monitor()
|
||||
{
|
||||
std::thread([this] {
|
||||
enqueue_command([this] {
|
||||
send_ws_rpc("camera.start_monitor",
|
||||
{{"domain", "lan"}, {"interval", 0}, {"expect_pw", false}});
|
||||
}).detach();
|
||||
});
|
||||
m_camera_last_fire_ms.store(now_ms());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user