Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-64000

Create a unlock/relock scope guard

    • Fully Compatible
    • v6.0
    • Service Arch 2022-06-27, Service Arch 2022-07-11
    • 1

      Create a new RAII type that receives a unique_lock, unlocks it, and locks it again upon destruction:

      stdx::unique_lock lk(mutex);
      ...
      {
          ScopedUnlockAndRelock scoped(lk);
          // Do work without holding the lock
      }
      

      One example for using this type is replacing the scope-guard in here:

              _inPoll = true;
              lk.unlock();
      
              const ScopeGuard guard([&] {
                  lk.lock();
                  _inPoll = false;
              });
      

            Assignee:
            erin.mcnulty@mongodb.com Erin McNulty
            Reporter:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: