]> git.eshelyaron.com Git - emacs.git/commit
Implement Lisp threading on Android
authorPo Lu <luangruo@yahoo.com>
Tue, 6 Feb 2024 09:52:33 +0000 (17:52 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 7 Feb 2024 10:54:37 +0000 (11:54 +0100)
commit984e8d85c636b7213e4659d61491a204d0500fed
treee4b109f8a5347dcf84ea514bde9e64a2f6893a53
parentacbe60335ce2b8ae01d6c124660a8b7d63b2d597
Implement Lisp threading on Android

Much like the NS port, only the main thread receives input from
the user interface, which is fortunately not a major problem for
packages such as lsp-mode that create Lisp threads.

* configure.ac: Enable with_threads under Android.

* src/android.c (android_init_events): Set `main_thread_id' to
the ID of the main thread.
(setEmacsParams): Set new global variable `android_jvm' to the
JVM object, for the purpose of attaching Lisp threads to the
JVM.
(android_select): [THREADS_ENABLED]: If the caller isn't the
main thread, resort to pselect.  Don't check query before select
returns.
(android_check_query): Export.

* src/android.h (_ANDROID_H_): Define new macro and update
prototypes.

* src/process.c (android_select_wrapper): New function.
(wait_reading_process_output): If THREADS_ENABLED, call
thread_select through the Android select wrapper.

* src/thread.c (post_acquire_global_lock): Call
android_check_query; replace android_java_env with the incoming
Lisp thread's.
(run_thread): Attach and detach the thread created to the JVM.
(init_threads): Set the main thread's JNI environment object.

* src/thread.h (struct thread_state) <java_env>: New field.

(cherry picked from commit 42db7292c3e05920bc9f2fa5c3478eb2ba835c5c)
configure.ac
src/android.c
src/android.h
src/process.c
src/thread.c
src/thread.h