implemented a read/write lock utility class in sideboard.lib#46
Merged
EliAndrewC merged 1 commit intoresyncing_with_publicfrom Dec 5, 2016
Merged
implemented a read/write lock utility class in sideboard.lib#46EliAndrewC merged 1 commit intoresyncing_with_publicfrom
EliAndrewC merged 1 commit intoresyncing_with_publicfrom
Conversation
Contributor
Author
|
Note: I branched this off of the |
Contributor
Author
|
Gonna merge this in now, because it's just merging into the |
EliAndrewC
added a commit
that referenced
this pull request
Mar 8, 2017
implemented a read/write lock utility class in sideboard.lib
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This feature has come up as something that would be useful both at my day job and in some of the MAGFest background tasks.
We want a lock with the following characteristics:
Locks are hard to write good unit tests for. I did add several unit tests for this feature, including one which spins up other threads to ensure that the locking works as expected. However, in order to REALLY test this out, I also wrote this script:
https://gist.github.com/EliAndrewC/2b23aa2bfb83b353abe5f64f0646c568
That script runs hundreds of threads at a time acquiring read and write locks. I can see from the output that all of the properties explained above are proven out, e.g. I can see that
I ran this script for many hours to ensure that there were no unexpected edge cases causing it to jam up. I also ensured that the CPU and memory usage was low to ensure that this implementation is efficient.