diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-30 21:21:55 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-30 21:21:55 -0400 |
| commit | e8a7dd0b8788f14b2ecc04ecaef8e77e4d2b68e1 (patch) | |
| tree | d24f88f40d31b7a4b67d69b0b4f3b12c87c1d6ee /uitask_darwin.go | |
| parent | 46ba0049cb80d8b6973c3146b40ceceaead710ed (diff) | |
Converted the Mac OS X backend to use uitask() instead of uitask chan func().
Diffstat (limited to 'uitask_darwin.go')
| -rw-r--r-- | uitask_darwin.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/uitask_darwin.go b/uitask_darwin.go index 754418c..5932cac 100644 --- a/uitask_darwin.go +++ b/uitask_darwin.go @@ -14,30 +14,25 @@ import ( // #include "objc_darwin.h" import "C" -var uitask chan func() +// can be run from any thread +// will wait for return; see delegateuitask_darwin.m +func uitask(f func()) { + C.douitask(appDelegate, unsafe.Pointer(&f)) +} func ui(main func()) error { runtime.LockOSThread() - uitask = make(chan func()) - 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)) - } - }() - go func() { main() - uitask <- func() { + uitask(func() { C.breakMainLoop() - } + }) }() C.cocoaMainLoop() |
