Expose main thread's looper for runOnUiThread compatibility#198
Expose main thread's looper for runOnUiThread compatibility#198rib merged 1 commit intorust-mobile:mainfrom
Conversation
53b965f to
edf5f87
Compare
This makes it possible to register file descriptors that can wake up the Java main / UI thread as well as callbacks that will run on the Java main / UI thread. Although it can be common to refer to this thread as the "main" thread, we choose to explicitly refer to it as the "java main" thread thread in the API to avoid confusion with the Rust thread that runs "android_main". Co-authored-by: Robert Bragg <robert@sixbynine.org>
|
Hi, sorry for taking a long time to look at this. Thanks, the idea seems good to me. I've rebased this and added corresponding support to the I've updated the implementation to expose The other change I made was to refer to this as the "java main" Looper and not just the "main looper" to avoid confusion with the thread/Looper that's associated with Based on this work, I have also experimented with building a more ergonomic |
|
For reference here, this is the follow up PR that adds a |
Posting to the UI thread is only possible via the looper obtained from the main activity thread.
android-activitycreates theAndroidAppinside a worker thread and there is no way to access the main thread's looper. Even interacting with the UI will send events into theAndroidAppInnerlooper and execute code in the worker thread.This PR simply records a pointer to the thread's looper before spawning the worker thread and makes it available in a similar fashion to the existing looper.
Related discussion:
#197