SenseApiLib:Add isBeingDestroyed atomic flag for getter bailout

Since we have no choice but to access the sh_ptr<SenseApiLib> for
a lib before we can get its Qutex, we use this flag to ensure that
we can know whether the SenseApiLib data structure and its Qutex
are still valid when we enter -- i.e, we ensure that the SenseApiLib
object wasn't destroyed under our feet.
This commit is contained in:
2025-09-30 20:48:45 -04:00
parent 1bad358921
commit 07609c6d6c
3 changed files with 30 additions and 32 deletions
+9
View File
@@ -228,6 +228,10 @@ std::string SenseApiManager::stringifyLibs() const
void SenseApiManager::initializeSenseApiLib(SenseApiLib& lib)
{
/** FIXME:
* When we eventually make this method async, this method should acquire
* the SenseApiManager's main CRUD qutex.
*/
if (!lib.senseApiDesc.sal_mgmt_libOps.initializeInd)
{
throw std::runtime_error(
@@ -239,6 +243,11 @@ void SenseApiManager::initializeSenseApiLib(SenseApiLib& lib)
void SenseApiManager::finalizeSenseApiLib(SenseApiLib& lib)
{
/** FIXME:
* When we eventually make this method async, this flag should only be set
* after acquiring the SenseApiManager's main CRUD qutex.
*/
lib.isBeingDestroyed.store(true);
if (!lib.senseApiDesc.sal_mgmt_libOps.finalizeInd)
{
throw std::runtime_error(