looper: Require Send when adding fd event callbacks on ForeignLooper#469
Merged
looper: Require Send when adding fd event callbacks on ForeignLooper#469
Send when adding fd event callbacks on ForeignLooper#469Conversation
09fc908 to
ecf32a1
Compare
MarijnS95
commented
Jan 27, 2024
ndk/src/looper.rs
Outdated
Comment on lines
+242
to
+243
| // let callback = unsafe { std::mem::transmute(callback) }; | ||
| // self.foreign.add_fd_with_callback(fd, events, callback) |
Member
Author
There was a problem hiding this comment.
A transmute doesn't seem to work here to deduplicate the two functions, unfortunately :/
ecf32a1 to
0669e53
Compare
0669e53 to
6d35e23
Compare
Member
Author
|
Found a way, |
`ForeignLooper` allows (re)registering callbacks on threads that are not the `ThreadLooper` (current) thread. Since these calls will be executed on that `ThreadLooper` thread when the user calls any of the `poll()` functions, these closures have to pass a thread boundary which requires `Send`.
6d35e23 to
9aa58be
Compare
MarijnS95
commented
Apr 26, 2024
| - native_window: Require linking against `libnativewindow` for most API >= 26 functions. (#465) | ||
| - **Breaking:** audio: Merge `AudioResult` variant enum into `AudioError`. (#467) | ||
| - data_space: Add missing `DataSpaceRange::Unspecified` variant. (#468) | ||
| - **Breaking:** looper: Require `Send` marker when adding fd event callbacks on `ForeignLooper`. (#469) |
Member
Author
There was a problem hiding this comment.
As soon as I click merge, I realized I should have probably mentioned that ThreadLooper::add_fd_with_callback() was added without the Send bound, if already on the same thread.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ForeignLooperallows (re)registering callbacks on threads that are not theThreadLooper(current) thread. Since these calls will be executed on thatThreadLooperthread when the user calls any of thepoll()functions, these closures have to pass a thread boundary which requiresSend.