Beispiel #1
0
func run(cb Callbacks) {
	// We want to keep the event loop on a consistent OS thread.
	runtime.LockOSThread()

	ctag := C.CString("Go")
	cstr := C.CString("app.Run")
	C.__android_log_write(C.ANDROID_LOG_INFO, ctag, cstr)
	C.free(unsafe.Pointer(ctag))
	C.free(unsafe.Pointer(cstr))

	if JavaInit != nil {
		JavaInit(uintptr(unsafe.Pointer(C.current_vm)))
	}

	// Inform Java that the program is initialized.
	C.pthread_mutex_lock(&C.go_started_mu)
	C.go_started = 1
	C.pthread_cond_signal(&C.go_started_cond)
	C.pthread_mutex_unlock(&C.go_started_mu)

	for {
		select {
		case w := <-windowCreated:
			windowDrawLoop(cb, w, queue)
		}
	}
}
Beispiel #2
0
// notifyInitDone informs Java that the program is initialized.
// A NativeActivity will not create a window until this is called.
func notifyInitDone() {
	C.pthread_mutex_lock(&C.go_started_mu)
	C.go_started = 1
	C.pthread_cond_signal(&C.go_started_cond)
	C.pthread_mutex_unlock(&C.go_started_mu)
}