[SERVER-64000] Create a unlock/relock scope guard Created: 25/Feb/22  Updated: 29/Oct/23  Resolved: 30/Jun/22

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 6.1.0-rc0, 6.0.6

Type: Improvement Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Erin McNulty
Resolution: Fixed Votes: 1
Labels: neweng, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-49950 Address issues with ClockSource::setA... Closed
is related to SERVER-63282 Refactor and simplify `BatonASIO` Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.0
Sprint: Service Arch 2022-06-27, Service Arch 2022-07-11
Participants:
Story Points: 1

 Description   

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;
        });



 Comments   
Comment by Githook User [ 13/Apr/23 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com', 'username': 'gewa24'}

Message: SERVER-64000: Create an unlock/relock scope guard.

(cherry picked from commit dbef08b92565ffc372b6eef21a1ea11a45c964c1)
Branch: v6.0
https://github.com/mongodb/mongo/commit/ff602671b255df68898b49faf5252a39b7b1761f

Comment by Githook User [ 30/Jun/22 ]

Author:

{'name': 'Erin McNulty', 'email': 'erin.mcnulty@mongodb.com', 'username': 'erin2722'}

Message: SERVER-64000: Create an unlock/relock scope guard
Branch: master
https://github.com/mongodb/mongo/commit/dbef08b92565ffc372b6eef21a1ea11a45c964c1

Generated at Thu Feb 08 05:59:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.