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

Add impl Spawn and LocalSpawn for Arc and Rc. #2039

Merged
merged 1 commit into from Jan 23, 2020

Conversation

najamelan
Copy link
Contributor

@najamelan najamelan commented Jan 19, 2020

Since #1950 (0.3.0) the Spawn and LocalSpawn only require a shared reference
for spawning operations.

This adds blanket impls for Arc<Sp: ?Sized + Spawn> and Rc<Sp: ?Sized + Spawn>.
It does the same for LocalSpawn.

This allows client code to pass an Arc when library code takes
parameters as &dyn Spawn or impl Spawn.

So far there were blanket impls for &, &mut and Box.

@najamelan
Copy link
Contributor Author

najamelan commented Jan 19, 2020

I don't know if something like this would make sense for Pin, but it's not included here. I could add it if that makes sense.

@najamelan najamelan requested a review from cramertj Jan 19, 2020
@najamelan
Copy link
Contributor Author

najamelan commented Jan 19, 2020

This seems to fail on thumbv6m-none-eabi. Move the Arc impl under std feature?

@taiki-e
Copy link
Member

taiki-e commented Jan 20, 2020

Move the Arc impl under std feature?

Could you use cfg_target_has_atomic macro for Arc impl?

@najamelan najamelan force-pushed the feature/impl_spawn_for_arc branch from b8bbfe4 to 1629373 Compare Jan 23, 2020
Since rust-lang#1950 (0.3.0) the Spawn and LocalSpawn only require a shared reference
for spawning operations.

This adds blanket impls for `Arc<Sp: ?Sized + Spawn>` and `Rc<Sp: ?Sized + Spawn>`.
It does the same for LocalSpawn.

This allows client code to pass an Arc<Exec> when library code takes
parameters as `&dyn Spawn` or `impl Spawn`.

So far there were blanket impls for `&`, `&mut` and `Box`.
@najamelan najamelan force-pushed the feature/impl_spawn_for_arc branch from 1629373 to 94fff6b Compare Jan 23, 2020
@najamelan
Copy link
Contributor Author

najamelan commented Jan 23, 2020

Limited Arc impl under cfg_target_has_atomic as suggested.

@cramertj cramertj merged commit 3f0e90c into rust-lang:master Jan 23, 2020
1 check passed
@cramertj
Copy link
Member

cramertj commented Jan 23, 2020

Thanks!

@najamelan
Copy link
Contributor Author

najamelan commented Jan 24, 2020

Awesome. Any idea when a version 0.3.2 might be released? Seems quite some work has happened since November.

@cramertj
Copy link
Member

cramertj commented Jan 24, 2020

I'll release one next week, thanks for asking!

@najamelan najamelan deleted the feature/impl_spawn_for_arc branch Feb 11, 2020
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.

None yet

3 participants