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

@ -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)) );
}
}
}