mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
Add some info about shared_ptr to weak_ptr future refactor
This commit is contained in:
parent
a5cdee6078
commit
5554f799c0
@ -37,6 +37,9 @@ class RsBroadcastDiscovery;
|
|||||||
/**
|
/**
|
||||||
* Pointer to global instance of RsBroadcastDiscovery service implementation
|
* Pointer to global instance of RsBroadcastDiscovery service implementation
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
*
|
||||||
|
* TODO: this should become std::weak_ptr once we have a reasonable services
|
||||||
|
* management.
|
||||||
*/
|
*/
|
||||||
extern std::shared_ptr<RsBroadcastDiscovery> rsBroadcastDiscovery;
|
extern std::shared_ptr<RsBroadcastDiscovery> rsBroadcastDiscovery;
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ class RsEvents;
|
|||||||
/**
|
/**
|
||||||
* Pointer to global instance of RsEvents service implementation
|
* Pointer to global instance of RsEvents service implementation
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
*
|
||||||
|
* TODO: this should become std::weak_ptr once we have a reasonable services
|
||||||
|
* management.
|
||||||
*/
|
*/
|
||||||
extern std::shared_ptr<RsEvents> rsEvents;
|
extern std::shared_ptr<RsEvents> rsEvents;
|
||||||
|
|
||||||
|
@ -170,10 +170,15 @@ void BroadcastDiscoveryService::data_tick()
|
|||||||
rbdr.locator.port() );
|
rbdr.locator.port() );
|
||||||
mRsPeers.connectAttempt(rbdr.mSslId);
|
mRsPeers.connectAttempt(rbdr.mSslId);
|
||||||
}
|
}
|
||||||
else if(rsEvents)
|
else
|
||||||
{
|
{
|
||||||
typedef RsBroadcastDiscoveryPeerFoundEvent Evt_t;
|
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)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user