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) } } }
// UnRef will allow the pointer to leave the CGO call, letting // the Go garbage collector clean/move it. func (this *CRef) UnRef() { C.pthread_mutex_unlock(&this.mut) C.pthread_mutex_destroy(&this.mut) }
// 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) }