diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-29 09:07:14 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-29 09:07:14 -0400 |
| commit | ed989a9d9ff615b37d4aa9b5eefc1aa0ba5fa071 (patch) | |
| tree | 13927d75ed697637f267b94be5d328dec4b22c08 /uitask_darwin.go | |
| parent | dff7ed33218f40980b7da57d730c47a43dd27522 (diff) | |
Migrated sysdata_darwin.go and uitask_darwin.go to the new API. Now to just wait for the answer to my Stack Overflow question so I can migrate dialog_darwin.go...
Diffstat (limited to 'uitask_darwin.go')
| -rw-r--r-- | uitask_darwin.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/uitask_darwin.go b/uitask_darwin.go index 754418c..695b5c5 100644 --- a/uitask_darwin.go +++ b/uitask_darwin.go @@ -16,32 +16,31 @@ import "C" var uitask chan func() -func ui(main func()) error { - runtime.LockOSThread() - - uitask = make(chan func()) - +func uiinit() error { err := initCocoa() if err != nil { return err } - // Cocoa must run on the first thread created by the program, so we run our dispatcher on another thread instead - go func() { - for f := range uitask { - C.douitask(appDelegate, unsafe.Pointer(&f)) - } - }() + // do this at the end in case something goes wrong + uitask = make(chan func()) + return nil +} +func ui() { + // Cocoa must run on the first thread created by the program, so we run our dispatcher on another thread instead go func() { - main() - uitask <- func() { - C.breakMainLoop() + for { + select { + case f := range uitask: + C.douitask(appDelegate, unsafe.Pointer(&f)) + case <-Stop: + C.breakMainLoop() + } } }() C.cocoaMainLoop() - return nil } func initCocoa() (err error) { |
