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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user