mirror of
https://github.com/netbirdio/gomobile-tvos-fork.git
synced 2026-05-22 18:43:29 -07:00
mobile/bind: ensure that Java->Go->Java calls stay on same thread
Java methods from Go are run on a thread pool managed on the Java side, to avoid the complexities of getting Go threads to play along with the Android JVM. However, for call stacks that contain a Java->Go->Java chain, this behaviour confuses Java code sensitive to specific threads if the Go->Java call is executed on an arbitrary thread from the pool. For example, most Android UI changes must happen on the single UI thread. Replace the thread pool with direct calls to mimic ObjC<->Go and Java->Go calls. Threads not already attached to the JVM are attached. Introduce a thread local variable to detach such threads at thread exit. Change-Id: I8cb65803c9278666ae77a0c7a65dc2d9c7e739e1 Reviewed-on: https://go-review.googlesource.com/19334 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
committed by
Hyang-Ah Hana Kim
parent
7538792349
commit
46f9e01d1e
@@ -3,3 +3,5 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
void init_seq(void* vm, void* classfinder);
|
||||
JNIEnv *get_thread_env(void);
|
||||
void recv(int32_t ref, int code, uint8_t *in_ptr, size_t in_len, uint8_t **out_ptr, size_t *out_len);
|
||||
|
||||
Reference in New Issue
Block a user