Merge 9b1890e48a
into 70a69d6ae3
This commit is contained in:
commit
606563e810
15
main.go
15
main.go
|
@ -3,8 +3,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
@ -42,6 +42,11 @@ func Main(f func()) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uninit calls C.uiUninit to uninitialize all allocated objects
|
||||||
|
func Uninit() {
|
||||||
|
C.uiUninit()
|
||||||
|
}
|
||||||
|
|
||||||
// Quit queues a return from Main. It does not exit the program.
|
// Quit queues a return from Main. It does not exit the program.
|
||||||
// It also does not immediately cause Main to return; Main will
|
// It also does not immediately cause Main to return; Main will
|
||||||
// return when it next can. Quit must be called from the GUI thread.
|
// return when it next can. Quit must be called from the GUI thread.
|
||||||
|
@ -52,9 +57,9 @@ func Quit() {
|
||||||
// These prevent the passing of Go functions into C land.
|
// These prevent the passing of Go functions into C land.
|
||||||
// TODO make an actual sparse list instead of this monotonic map thingy
|
// TODO make an actual sparse list instead of this monotonic map thingy
|
||||||
var (
|
var (
|
||||||
qmmap = make(map[uintptr]func())
|
qmmap = make(map[uintptr]func())
|
||||||
qmcurrent = uintptr(0)
|
qmcurrent = uintptr(0)
|
||||||
qmlock sync.Mutex
|
qmlock sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueueMain queues f to be executed on the GUI thread when
|
// QueueMain queues f to be executed on the GUI thread when
|
||||||
|
@ -64,11 +69,11 @@ var (
|
||||||
// primary purpose is to allow communication between other
|
// primary purpose is to allow communication between other
|
||||||
// goroutines and the GUI thread. Calling QueueMain after Quit
|
// goroutines and the GUI thread. Calling QueueMain after Quit
|
||||||
// has been called results in undefined behavior.
|
// has been called results in undefined behavior.
|
||||||
//
|
//
|
||||||
// If you start a goroutine in f, it also cannot call package ui
|
// If you start a goroutine in f, it also cannot call package ui
|
||||||
// functions. So for instance, the following will result in
|
// functions. So for instance, the following will result in
|
||||||
// undefined behavior:
|
// undefined behavior:
|
||||||
//
|
//
|
||||||
// ui.QueueMain(func() {
|
// ui.QueueMain(func() {
|
||||||
// go ui.MsgBox(...)
|
// go ui.MsgBox(...)
|
||||||
// })
|
// })
|
||||||
|
|
Loading…
Reference in New Issue