[DOCS-8924] RAII semantics for ReplicaSetMonitor Created: 28/Sep/16  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-23345 RAII semantics for ReplicaSetMonitor Closed
Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769

 Description   

Delegate the cleanup of resources used by ReplicaSetMonitor the do its d-tor. Currently its done in ReplicaSetMonitor::remove() .

a) Change ReplicaSetMonitorManager _monitors type to StringMap<std::weak_ptr<RepliceSetMonitor>>
so the map does not own monitors and hence every object will call a d-tor as soon as its refcount is 0

b) ReplicaSetMonitor::~ReplicaSetMonitor will now be called when it goes out of scope and hence it should erase itself from the _monitors map.

c) ReplicaSetMonitorManager::getMonitor should
lock() a weak_ptr to existing monitor to convert it to shared_ptr() before returning it. It should invariant that lock() works i.e. the map can not have a dangling weak_ptr.

d) disallow calling ReplicaSetMonitor::remove() - make its private or delete if not needed

e) Optionally in the case there is need to get a shared_ptr from ReplicaSetMonitor object: derive ReplicaSetMonitor from enable_shared_from_this and use shared_from_this() call to get shared_ptr.



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Generated at Thu Feb 08 07:57:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.