Add some info about shared_ptr to weak_ptr future refactor

This commit is contained in:
Gioacchino Mazzurco 2019-04-15 10:37:21 +02:00
parent a5cdee6078
commit 5554f799c0
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 13 additions and 2 deletions

View File

@ -37,6 +37,9 @@ class RsBroadcastDiscovery;
/**
* Pointer to global instance of RsBroadcastDiscovery service implementation
* @jsonapi{development}
*
* TODO: this should become std::weak_ptr once we have a reasonable services
* management.
*/
extern std::shared_ptr<RsBroadcastDiscovery> rsBroadcastDiscovery;

View File

@ -33,6 +33,9 @@ class RsEvents;
/**
* Pointer to global instance of RsEvents service implementation
* @jsonapi{development}
*
* TODO: this should become std::weak_ptr once we have a reasonable services
* management.
*/
extern std::shared_ptr<RsEvents> rsEvents;

View File

@ -170,10 +170,15 @@ void BroadcastDiscoveryService::data_tick()
rbdr.locator.port() );
mRsPeers.connectAttempt(rbdr.mSslId);
}
else if(rsEvents)
else
{
typedef RsBroadcastDiscoveryPeerFoundEvent Evt_t;
rsEvents->postEvent(std::unique_ptr<Evt_t>(new Evt_t(rbdr)));
// Ensure rsEvents is not deleted while we use it
std::shared_ptr<RsEvents> lockedRsEvents = rsEvents;
if(lockedRsEvents)
lockedRsEvents->postEvent(
std::unique_ptr<Evt_t>(new Evt_t(rbdr)) );
}
}
}