mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
b simulators
Add mutex Add lock guard in invoke_active_simulator Add lock guard in changed_UI_items
This commit is contained in:
@@ -75,6 +75,7 @@ std::vector<std::string> Simulators::list_simulators() const
|
|||||||
|
|
||||||
Simulator_base* Simulators::invoke_active_simulator()
|
Simulator_base* Simulators::invoke_active_simulator()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (this->m_simulators.empty())
|
if (this->m_simulators.empty())
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -91,6 +92,7 @@ Simulator_base* Simulators::invoke_active_simulator()
|
|||||||
|
|
||||||
json Simulators::changed_UI_items()
|
json Simulators::changed_UI_items()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (this->m_simulators.empty())
|
if (this->m_simulators.empty())
|
||||||
{
|
{
|
||||||
return "{}"_json;
|
return "{}"_json;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include "simulator_base.hpp"
|
#include "simulator_base.hpp"
|
||||||
|
|
||||||
@@ -19,5 +20,6 @@ class Simulators {
|
|||||||
private:
|
private:
|
||||||
std::map<std::string, std::unique_ptr<Simulator_base>> m_simulators;
|
std::map<std::string, std::unique_ptr<Simulator_base>> m_simulators;
|
||||||
std::string m_current_simulator = "";
|
std::string m_current_simulator = "";
|
||||||
|
std::mutex m_mutex;
|
||||||
json m_before;
|
json m_before;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user