sys_config: Move cleanup to IDM abort

This commit is contained in:
Elad 2024-12-23 15:13:14 +02:00
parent 4d0c835df3
commit 3bf735161f
4 changed files with 47 additions and 9 deletions

View File

@ -693,7 +693,7 @@ public:
if constexpr (std::is_assignable_v<Context&, thread_state>) if constexpr (std::is_assignable_v<Context&, thread_state>)
{ {
static_cast<Context&>(*this) = s; static_cast<Context&>(*this) = thread_state::aborting;
} }
if (notify_sync) if (notify_sync)
@ -706,6 +706,11 @@ public:
{ {
// This participates in emulation stopping, use destruction-alike semantics // This participates in emulation stopping, use destruction-alike semantics
thread::join(true); thread::join(true);
if constexpr (std::is_assignable_v<Context&, thread_state>)
{
static_cast<Context&>(*this) = thread_state::finished;
}
} }
return *this; return *this;

View File

@ -109,10 +109,29 @@ void lv2_config::add_service_event(shared_ptr<lv2_config_service_event> event)
void lv2_config::remove_service_event(u32 id) void lv2_config::remove_service_event(u32 id)
{ {
shared_ptr<lv2_config_service_event> ptr;
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
events.erase(id);
if (auto it = events.find(id); it != events.end())
{
ptr = std::move(it->second);
events.erase(it);
}
} }
lv2_config_service_event& lv2_config_service_event::operator=(thread_state s) noexcept
{
if (s == thread_state::finished)
{
if (auto global = g_fxo->try_get<lv2_config>())
{
global->remove_service_event(id);
}
}
return *this;
}
// LV2 Config Service Listener // LV2 Config Service Listener
bool lv2_config_service_listener::check_service(const lv2_config_service& service) const bool lv2_config_service_listener::check_service(const lv2_config_service& service) const

View File

@ -390,13 +390,9 @@ public:
} }
// Destructor // Destructor
~lv2_config_service_event() noexcept lv2_config_service_event& operator=(thread_state s) noexcept;
{
if (auto global = g_fxo->try_get<lv2_config>()) ~lv2_config_service_event() noexcept = default;
{
global->remove_service_event(id);
}
}
// Notify queue that this event exists // Notify queue that this event exists
bool notify() const; bool notify() const;

View File

@ -801,6 +801,15 @@ public:
} }
} }
if constexpr (std::is_assignable_v<Get&, thread_state>)
{
if (ptr)
{
constexpr thread_state finished{3};
*static_cast<Get*>(ptr.get()) = finished;
}
}
return true; return true;
} }
@ -824,6 +833,15 @@ public:
} }
} }
if constexpr (std::is_assignable_v<Get&, thread_state>)
{
if (ptr)
{
constexpr thread_state finished{3};
*static_cast<Get*>(ptr.get()) = finished;
}
}
return true; return true;
} }