Add minimal tests for read_lock_required/write_lock_required and also add support for std::scoped_lock #611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why is this change being made?
Yesterday someone on my team was changing the lock type in some code and hit problems because
std::scoped_lockis not on the supported list forwil::read_lock_required/wil::write_lock_required. It seems like they really should be supported, so that's why this PR is being sent.When I went to add this support I wanted to use the tests to verify expectations for what compiles and what doesn't. I then realized that there is no test coverage for this so I am adding the examples that I used for my local verification. These are basically "does it compile" tests and can never really fail at runtime.
Briefly summarize what changed
Add a specialization of
exclusive_lock_proofforstd::scoped_lock. Add new test coverage for the lock traits.As best as I can tell scoped_lock is only for mutexes in STL and therefore is always going to be exclusive. If I am mistaken then please let me know and this should be limited to a more limited shared_lock_proof (or somehow detect the underlying mutex type?).
How was this change tested?
init_all.cmd + build_all.cmd + runtests.cmd. Also ran clang format.