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

chore(ffi): introduce AsyncRuntimeDropped helper #4168

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Oct 25, 2024

This avoids proliferation of ManuallyDrop in the code base, by having
a single type that's used for dropping under an async runtime.


I actually saw three uses of ManuallyDrop on the FFI layer, but failed to notice that two of them were in the crypto FFI crate. Should I introduce a new FFI helper crate just for sharing this code across the two other crates?

@bnjbvr bnjbvr changed the title Ffi/avoid proliferation of manuallydrop chore(ffi): introduce AsyncRuntimeDropped helper Oct 25, 2024
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.88%. Comparing base (5d141fc) to head (a9b4867).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4168   +/-   ##
=======================================
  Coverage   84.88%   84.88%           
=======================================
  Files         272      272           
  Lines       29133    29133           
=======================================
  Hits        24730    24730           
  Misses       4403     4403           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This avoids proliferation of `ManuallyDrop` in the code base, by having
a single type that's used for dropping under an async runtime.
@bnjbvr bnjbvr force-pushed the ffi/avoid-proliferation-of-manuallydrop branch from 1985150 to a9b4867 Compare November 4, 2024 13:16
@bnjbvr bnjbvr marked this pull request as ready for review November 4, 2024 13:18
@bnjbvr bnjbvr requested a review from a team as a code owner November 4, 2024 13:18
@bnjbvr bnjbvr requested review from poljar and removed request for a team November 4, 2024 13:18
@bnjbvr
Copy link
Member Author

bnjbvr commented Nov 4, 2024

Rebased, so ready for review. Still an open question if we want to share code between the two FFI crates, so it's possible to share this reusable thing with the crypto crate (that uses the same pattern twice).

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

No need to share the code I would say.

/// This is useful whenever such a data type may transitively call some
/// runtime's `block_on` function in their `Drop` impl (since we lack async drop
/// at the moment), like done in some `deadpool` drop impls.
pub(crate) struct AsyncRuntimeDropped<T>(ManuallyDrop<T>);
Copy link
Member

Choose a reason for hiding this comment

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

Yes please!

@bnjbvr bnjbvr merged commit c08194a into main Nov 4, 2024
53 of 76 checks passed
@bnjbvr bnjbvr deleted the ffi/avoid-proliferation-of-manuallydrop branch November 4, 2024 13: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