-
Notifications
You must be signed in to change notification settings - Fork 105
Locations info continued + handle mod cleanup + downcasts #173
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
Conversation
|
@mulimoen Interesting, I can't figure out why the tests fail (on 1.10.6) for datasets but not groups? I.e., you create a group and check its location info and times are filled out, but not for datasets. Am I missing something? |
|
|
Do you mot need to turn time tracking on when creating the dataset? |
c15ac69 to
1463a68
Compare
|
Needs a bit of version juggling (doing it now), changelog update and maybe a few docstrings, but almost finished all in all. (Aside from loc info, contains a few todos I've had for a while - clean up |
| Err(From::from(format!("Invalid handle id: {}", id))) | ||
| } | ||
| }) | ||
| let handle = Self { id }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we should keep and use the free-standing functions here instead of creating an invalid handle. Forgetting to forget the handle could invalidate other unrelated objects and be very hard to track down. If one panics in is_valid_user_id one could also be in the same position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could happen if Mutex is poisoned, although the state of this library would be in a poor shape if that was to happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point, I think, there's literally few lines of code where this is needed - and they would continue to work largely the same with the change. I.e., the compiled code will be pretty much identical; the only difference is that now ObjectClass::from_id checks for handle validitity first and then the id type match - which is more correct way of doing it anyways. So, we contain all handle-like low-level stuff in Handle and enclose it completely, without any free-standing functions etc. I would argue that for a newcoming contributor, too, this would be much easier to read since it's not obvious where those free-standing functions belong to and why are they pub-re-exported.
// Also, if is_valid_user_id panics, it's a panic, and after any panic all promises are broken anyway? (and it's almost surely a straight crash regardless). And you're right, with a poisoned mutex all the things around are mostly already dead anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a comment above each forget with
// Drop on invalid handle could cause close of unrelated objectto clearly document why this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the free-standing functions be moved to this scope and not exported? It is feasible to guarantee a Handle always being valid if we make decref() pub(crate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the free-standing functions be moved to this scope and not exported? It is feasible to guarantee a
Handlealways being valid if we makedecref()pub(crate)
Heh - I was suggesting something similar just in a previous PR - we can make both incref/decref pub(crate) and then there's no need for free-standing functions, Handle is guaranteed to be valid, and no checks are needed in incref/decref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Handle::invalid() would also have to be killed then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a PR after this for invalid handles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another valid case to mention that doesn't involve manual decref - File::close(). However, it takes self by value, so it should be all good...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File::close needs a better comment, it must be closed with H5Fclose because of the file close degree
This PR aims to finish the work on locations, location info etc. One reason is that times / num attrs would never be filled out - which needs to be handled.