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

Loosen Send/Sync bounds on futures #48

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

Jules-Bertholet
Copy link
Collaborator

This ensures that Send/Sync bounds for each future match those of the value produed by the future.

Copy link
Member

@zeenix zeenix left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

src/mutex.rs Show resolved Hide resolved
Copy link
Member

@zeenix zeenix left a comment

Choose a reason for hiding this comment

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

LGTM. @notgull @taiki-e ?

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

I'm not sure if this is the right approach. I'd prefer to modify the underlying Future types in order to make the trait resolver automatically classify them as Sync. If they contain types that aren't Send/Sync (like raw pointers) then those types should be wrapped to make them Send/Sync.

Instead of this:

struct Foo {
    data: *const (),
    other_data: u32
}

unsafe impl Send for Foo {}

I would do this:

struct Foo {
    data: PtrWrapper,
    other_data: u32
}

struct PtrWrapper(*const ());
unsafe impl Send for PtrWrapper {}

This ensures that `Send`/`Sync` bounds for each future
match those of the value produed by the future.
Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Thanks!

@notgull notgull merged commit d22ee4e into smol-rs:master Jun 15, 2023
@Jules-Bertholet Jules-Bertholet deleted the future-send-sync branch June 15, 2023 01:10
@notgull notgull mentioned this pull request Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants