-
Notifications
You must be signed in to change notification settings - Fork 52
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
Simplify and make Request safer #18
Conversation
e0e1940
to
6cbe9d5
Compare
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.
Nice work! Just a few nits:
- I would prefer to separate the inactive request stuff out into another PR.
- Requests should be deregistered from their scope when the associated operations are completed via explicitly calling a method or wrapping the request in a completion guard. This actually makes some of the examples fail. Unfortunately I forgot to return a non-zero exit status from one of the CI scripts, so it does not show up on Travis.
Some questions on design:
|
63882b8
to
dda0458
Compare
Changes since yesterday:
|
0ee0a4e
to
b513eec
Compare
So I started working on a separate branch to generalize buffer types to support
|
b513eec
to
1705de3
Compare
Regarding the questions about the semantics of dropping or forgetting requests:
I am starting to wonder whether it would make sense to have the requests be owned by the scope. This would probably simplify all this cleaning up, but I think it would take away the ability to enforce a certain order of request completion. |
I must admit I am a bit confused by the refactoring in requests.rs. The former design where |
Your other work definitely sounds interesting and I am grateful that you are investing time into this project. For the moment, I would like to focus on this PR first and move to the generalisation of buffers afterwards, if you have the patience. I am currently also juggling a regular day job, a move and a newborn, so time and mental space is scarce. |
IMO I think parametrizing
When I tried it, it seemed that |
1705de3
to
558d855
Compare
970fa75
to
55a6b91
Compare
Created two kinds of Scope objects: - LocalScope<'a> to track Requests with arbitrary lifetime 'a - StaticScope (no bookkeeping, but only 'static Requests) The Request trait has been squashed into a single Request<'a, S> data type, where S is the type of scope that this Request is associated with and 'a describes the lifetime of this scope. Any buffers associated with the request must outlive 'a. Fixes # 17.
This simplifies the implementation and efficiency of LocalScope significantly and can reduce the risk of an accidental deadlock.
dc503c3
to
5af7238
Compare
True, this is why It may be somewhat redundant to wrap the |
Are there any changes that need to be made to complete this PR? |
Not necessarily. I would still like to see the |
Okay I’ve moved the logic into Request. I originally tried putting it in RawRequest to avoid the Option but that just made other parts more complicated. You can squash/rebase them if you want. Having |
Wow, again, thank you so much. Looking again at my original implementation, I notice that I misremembered and my I also noticed just now, that my implementation of I have one more question which I will leave as an in-line comment immediately.
Yes, I remember having the exact same reaction. It reminds me of the C++ move semantics. "Yep, this value is yours. If you want to trash it, go ahead. What? No, you don't actually get to have the value. Here, have this reference instead." |
src/request.rs
Outdated
|
||
/// Wait for the request to finish and unregister the request object from its scope. | ||
/// | ||
/// This is unsafe because afterward the request is left in an unspecified but droppable state. |
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.
Is this a leftover from an earlier version? The method is not marked unsafe
and the Rust Request
type is deconstructed by the call to into_raw()
so I do not get what the unspecified but droppable state
is?
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.
Yeah this was from back when it took &mut self
instead of self
.
Ugh, apparently I had not figured out how these review things work. I left the in-line comment yesterday, but only noticed today that I needed to submit the whole review. Sorry about that. |
Should be fixed now! |
Great, let's get this merged! |
Created two kinds of
Scope
objects:LocalScope
to trackRequest
s with arbitrary lifetime'a
StaticScope
(no bookkeeping, but only'static
Request
s)The
Request
trait has been squashed into a singleRequest<S>
data type, whereS
is the type of scope that thisRequest
is associated with.Fixes #17.
Scope
.LocalScope
to an innerLocalScope
.It would be nice to generalize(WIP: Rufflewind:bindgen-hack...Rufflewind:buffer)Buffer
to allow things likeRc
, which would be compatible withStaticScope
.