Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-8924

RAII semantics for ReplicaSetMonitor

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • Server
    • None

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            emily.hall Emily Hall
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago