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

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
Copy link
Contributor Author

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?

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
Copy link
Contributor Author

Limited Arc impl under cfg_target_has_atomic as suggested.

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

Thanks!

@najamelan
Copy link
Contributor Author

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

@cramertj
Copy link
Member

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

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

3 participants