Skip to content
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

Update to latest nightly, removing LocalWaker and introducing ArcWake #1

Merged
merged 3 commits into from
Apr 17, 2019

Conversation

tinco
Copy link
Contributor

@tinco tinco commented Mar 31, 2019

I didn't really delve into the implications of these changes, I noticed the project no
longer compiled on nightly, and found this PR:

rust-lang/rust#57992

So I basically mapped the new unit tests in there to this project, until
this project compiled again. Then I ran the suite and it passed so
I reckon it at least sort of works. It definitely needs a review
by someone who actually understands the code (hoping that is you ;))

src/arc_wake.rs Outdated
@@ -0,0 +1,78 @@
// From htttps://github.com/rust-lang/rustc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I pulled this file from rust-lang/rustc I included their LICENSE-MIT in the top of the file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good :) However, the license also needs to be shipped with binary releases. We're not hosting any of those here, so technically this repository is fine. But if people use this crate as dependency, they'll almost certainly miss the license if it's not in the LICENSE file.

Could you add the license to the LICENSE file instead, below the BSD license, with a note that it applies to this file?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment about the origin of the file is nice anyway, lets keep that in here.

@de-vri-es
Copy link
Owner

Thanks for the PR! I'll need some time to properly review this, since wakers aren't the easiest thing in the world to do safely. I'd kinda like to avoid the inclusion of ArcWaker, but I'll have to get up to speed with the current state of futures first to see if that's feasible.

Copy link
Owner

@de-vri-es de-vri-es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some more time to review the PR. I believe it indeed restores functionality correctly.

It may actually be possible to map the Waker and Notifier traits to each-other without creating an Arc, but that was already on the TODO list anyway. So lets merge this with Arc, and I'll see it can be done without them later.

Just one reply to your comment regarding the license that we should sort out first.

src/arc_wake.rs Outdated
@@ -0,0 +1,78 @@
// From htttps://github.com/rust-lang/rustc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good :) However, the license also needs to be shipped with binary releases. We're not hosting any of those here, so technically this repository is fine. But if people use this crate as dependency, they'll almost certainly miss the license if it's not in the LICENSE file.

Could you add the license to the LICENSE file instead, below the BSD license, with a note that it applies to this file?

@tinco
Copy link
Contributor Author

tinco commented Apr 12, 2019

Like this? :)

@tinco
Copy link
Contributor Author

tinco commented Apr 12, 2019

Oh jeez :P I'm at my work so I can't really do work on fixing this right now. Maybe in the weekend..

@de-vri-es
Copy link
Owner

Yeah the license is great like that. But it seems we've been caught up by rust development again :p

@de-vri-es
Copy link
Owner

de-vri-es commented Apr 12, 2019

I tried to fix it, which ironically seemed to require removing ArcWake. The vtable now has to be passed to RawWaker as &'static, which doesn't seem possible with a generic type argument (though I may have overlooked a way, I'm not sure).

Either way, I made a vtable for TaskWaker instead, which doesn't have any type arguments. Would you mind double-checking that I didn't mess anything up with leaking and dropping the boxed TaskWaker?

Also, my apolagies for pushing to your fork, I always get a bit paranoid when that happens. In case you didn't know, github allows that by default for collaborators of the target repository for a PR (but you can disable it).


impl TaskWaker {
unsafe fn into_raw_waker(task: futures::task::Task) -> RawWaker {
let data = Box::leak(Box::new(task)) as *const _ as *const ();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on with the double as .., is that necessary?

Copy link
Owner

@de-vri-es de-vri-es Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you can't cast directly to a pointer of a different type, but you can cast pointers to pointers of different types. So first it casts to a *const futures::task::Task (abbreviated as *const _), then to a *const ().

@de-vri-es
Copy link
Owner

I'll go ahead and merge. Thanks for the PR, I hadn't even noticed it was broken yet :)

@de-vri-es de-vri-es merged commit 6218579 into de-vri-es:master Apr 17, 2019
@de-vri-es
Copy link
Owner

heh, it already didn't compile anymore. Fixed in 940ccd9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants