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

Implement Send for all 4 structs #30

Open
Mikadore opened this issue Jul 4, 2021 · 3 comments
Open

Implement Send for all 4 structs #30

Mikadore opened this issue Jul 4, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Mikadore
Copy link

Mikadore commented Jul 4, 2021

Is your feature request related to a problem? Please describe.
It's really painful to work with e.g. tokio::tasks with non-send types.

Describe the solution you'd like
Implement send for the 4 relevant structs:

unsafe impl Send for Microphone {}
unsafe impl Send for MicrophoneStream {}
unsafe impl Send for Speakers {}
unsafe impl Send for SpeakersSink {}

Describe alternatives you've considered
Wrapping the structs in user code, very unergonomic.

Additional context
This should be safe without any other changes.

@AldaronLau
Copy link
Member

@Mikadore thanks! This seems like a good change.

@AldaronLau AldaronLau added the enhancement New feature or request label Jul 4, 2021
@AldaronLau AldaronLau self-assigned this Jul 4, 2021
@polygon
Copy link

polygon commented Feb 26, 2022

Any progress on this? I've been trying to use wavy with bevy which also has a thread pool executor and ran into the same issue.

@AldaronLau
Copy link
Member

@polygon Looking at the data within each struct, I don't think I can do an unsafe impl Send for _ {} and still be sound. The ALSA documentation states it's thread-safe when compiled with the proper flag, but I want wavy to still be sound when ALSA is compiled without that flag. I've been working on a new version for about a year interspersed with work in many other projects, and hoping to release it soon. Future versions shouldn't take as long.

My current idea is to use a separate thread to run ALSA calls on and send data over a channel. I thought about using flume for this, but I don't want to pull in the https://crates.io/crates/pin-project dependency. I'll make sure to get this in when the new version does come out. In the meantime, if you need a workaround, you should be able to solve the problem the same way - by making an abstraction layer over wavy using channels.

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

No branches or pull requests

3 participants