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.
Description
The original
OpenMPMutex
class definition deletes the copy operator and copy assignment operators. This was a reasonable strategy, as if we copy this object then only a shallow copy is performed (i.e., destroying the original object will uninitialize theomp_lock_t
within the new copied object). While deletion of these operators works, it also precludes the class from being stored in various STL containers that might need to copy or move the objects (e.g.,std::vector
).Given that
omp_lock_t
objects are inherently fungible, we can just define the copy operators with default construction. I.e., copying just creates a new object, it does not copy anything from the original object. This allows for usage of the object in STL containers like vectors.For performance, we might also want to implement move operators, but I'm hesitant to introduce even more code that may not be used and likely isn't going to be covered by testing. Additionally, as movement of locks would only ever be done during program initialization, there is no tangible benefit to the move semantics, so probably not worth the extra code.
Checklist