-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ownership #51
Merged
Merged
Ownership #51
Conversation
This file contains 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
One can have two VariableMut active, but one can not have mutable access to the same VariableMut. Ownership, and the lack of Clone (and using PhantomData<&mut>) for mutable accessses disallows sharing the variable across threads. This means a lock is not necessary when writing to a variable
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
==========================================
- Coverage 86.87% 84.74% -2.14%
==========================================
Files 7 7
Lines 1280 1278 -2
==========================================
- Hits 1112 1083 -29
- Misses 168 195 +27
Continue to review full report at Codecov.
|
1e2677c
to
da000d0
Compare
Closed
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 is a complete revamp of ownership and caching of the file. The rust side is now not reading more than strictly necessary, and instead goes through
netcdf-c
. The ownership is now determined byPhantomData
, which prevents early dropping of theFile
.Multiple
VariableMut
can be held simultaneously (from different groups or fromvariables_mut
), with thePhantomData
preventing data races. This change should decrease memory usage of the library, especially when not reading all attributes of a file, as onlynetCDF-c
holds the metadata (fixes #44).The library might be a bit more annoying to use, as almost all operations can fail in the
netcdf-c
layer. Some unwrapping can probably be done on the library side, so application users can deal with an easier API. I am leaving this as a future exercise.