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

Fix multiple async packages not working together #46

Merged
merged 1 commit into from
Mar 14, 2024
Merged

Conversation

arg0d
Copy link
Collaborator

@arg0d arg0d commented Mar 14, 2024

Future continuation callback is a single global callback on Rust side. Its used to signal bindings from Rust when a future is ready. The problem is if multiple async packages set this callback, only one of these callbacks will be used by Rust code for futures from both packages.

The current implementation of this callback simply sends the continuation future result into a channel, but the channel type was using C.int8_t, which turns out to be a different type for each package, and channel raises an error when wrong type is being sent in the channel.

Luckily this callback is very simple, and it doesn't matter which package's callback is trigerred. So the fix is to use a channel type that is the same for both packages, regular int8 instead of C.int8_t.

Fixes #45

Future continuation callback is a single global callback on Rust side.
Its used to signal bindings from Rust when a future is ready. The
problem is if multiple async packages set this callback, only one of
these callbacks will be used by Rust code for futures from both
packages.

The current implementation of this callback simply sends the
continuation future result into a channel, but the channel type was
using `C.int8_t`, which turns out to be a different type for each
package, and channel raises an error when wrong type is being sent in
the channel.

Luckily this callback is very simple, and it doesn't matter which
package's callback is trigerred. So the fix is to use a channel type
that is the same for both packages, regular `int8` instead of `C.int8_t`.
@arg0d arg0d requested a review from Savolro March 14, 2024 09:19
@arg0d
Copy link
Collaborator Author

arg0d commented Mar 14, 2024

@kegsay this should unblock you from creating a test for #44, right?

@kegsay
Copy link
Contributor

kegsay commented Mar 14, 2024

I believe so, I'll merge your branch in and give it a go, thanks!

@arg0d arg0d requested a review from Lipt0nas March 14, 2024 09:47
Copy link
Member

@Lipt0nas Lipt0nas left a comment

Choose a reason for hiding this comment

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

Looks good!

@arg0d arg0d merged commit 880251c into main Mar 14, 2024
3 checks passed
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.

It's not possible to have 2 libraries which use async functions
3 participants