Create a unlock/relock scope guard

XMLWordPrintableJSON

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

      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
              Reporter:
              Amirsaman Memaripour
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: