Skip to content

Commit

Permalink
#5532: Change ScopedBoolLock to revert the attached boolean to its pr…
Browse files Browse the repository at this point in the history
…evious value on destruction
  • Loading branch information
codereader committed Mar 21, 2021
1 parent 7b4c12e commit 509bcbb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libs/util/ScopedBoolLock.h
Expand Up @@ -8,20 +8,22 @@ namespace util
class ScopedBoolLock
{
bool& _target;
bool _previousValue;

public:

/// Construct and set target to true
ScopedBoolLock(bool& target) :
_target(target)
_target(target),
_previousValue(target)
{
_target = true;
}

/// Destroy and set target to false
/// Destroy and set target to the previous value
~ScopedBoolLock()
{
_target = false;
_target = _previousValue;
}
};

Expand Down

0 comments on commit 509bcbb

Please sign in to comment.