Merged
Conversation
267c3e3 to
643a16d
Compare
This was referenced Mar 12, 2026
643a16d to
a087094
Compare
This makes it easy to schedule boxed closures to be run on the Java main / ui thread. When the closure is run then: - Any panic will be caught, so we don't unwind into the Looper and abort the process - The JVM will be attached (for JNI) and any exceptions that are thrown will be caught and logged as errors. - A JNI stack frame will be pushed and popped before running your closure (so you don't have to worry about leaking local JNI references) This bumps the jni dependency to 0.22.4 because that version adds a `JCharSequence` binding that we use in the `Toast` example in the documentation.
a087094 to
49bbf6c
Compare
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.
This makes it easy to schedule boxed closures to be run on the Java main / ui thread.
When the closure is run:
As an example, here's how the API could be used to send a
Toastvia JNI on the Java main / UI thread:I've added the above example to the API documentation for
run_on_java_main_threadand I also plan to updatena-mainloopto demonstrate the same thing.Note: I've tested the above snippet in a locally modified
na-mainloopbut since the in-tree example has got very out-of-date, I'll add this example usage ofrun_on_java_main_threadvia a separate PR