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>
8 lines
336 B
C
8 lines
336 B
C
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// 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);
|