Call a function on the Android main (GUI) thread.
hcl
android-funcall-in-main-thread func &rest args
android-funcall-in-main-thread-list func-and-args
func⇩ |
A function designator. |
args⇩ |
Arguments for func. |
func-and-args⇩ |
A cons (func . args). |
The functions android-funcall-in-main-thread
and android-funcall-in-main-thread-list
arrange for func to be applied to args on the Android main thread (which is the GUI thread too). android-funcall-in-main-thread
actually does it by consing func and args and calling android-funcall-in-main-thread-list
with the result. android-funcall-in-main-thread-list
is the "primitive" interface.
The invocation of the function is done by the event loop of the GUI thread, so it is synchronous with respect to processing events, in other words it will not happen in the middle of processing an event.
These functions should be used when func does something that needs to run on the main thread, most commonly operations that interact with GUI elements.
To allow for testing, these functions can be called on any architecture. On non-Android architectures, there is no "Android main process". In this case, android-funcall-in-main-thread-list
first tests whether the variable *android-main-process-for-testing* is non-nil (which value must be a process), and if it is sends func-and-args to this process by process-send. This is based the assumption that this process processes cons events by applying the cl:car to the cl:cdr, which is the "normal" behavior of the system event processing (that is, what general-handle-event does). If you set this variable, make sure that this process processes events in this way. If *android-main-process-for-testing* is nil
, android-funcall-in-main-thread-list
arranges for the idle process to apply the cl:car to the cl:cdr.
android-funcall-in-main-thread-list
always queues the function, even if it runs on the main thread. If you need to execute immediately when running on the main thread, check first using android-main-thread-p.
*android-main-process-for-testing*
android-main-thread-p
16 Android interface
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35