diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-12 20:00:29 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-12 20:00:29 -0400 |
| commit | 55f7a9638ebcd2dfb78394cf396f2edac926baaf (patch) | |
| tree | 64cca732f0d86f55215e20cd89c3442cb6f45231 /uitask_unix.go | |
| parent | 1729764db8663b677c438673ab86dcfdb1444f27 (diff) | |
Changed the way uitask is dispatched on GTK+ to make event handling not a CPU hog.
Diffstat (limited to 'uitask_unix.go')
| -rw-r--r-- | uitask_unix.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/uitask_unix.go b/uitask_unix.go index 9b22635..1ccc621 100644 --- a/uitask_unix.go +++ b/uitask_unix.go @@ -18,15 +18,19 @@ func ui(main func()) error { return fmt.Errorf("gtk_init failed (reason unknown; TODO)") } - // thanks to tristan in irc.gimp.net/#gtk - gdk_threads_add_idle(func() bool { - select { - case f := <-uitask: - f() - default: // do not block + // thanks to tristan and Daniel_S in irc.gimp.net/#gtk + // see our_idle_callback in callbacks_unix.go for details + go func() { + for f := range uitask { + done := make(chan struct{}) + gdk_threads_add_idle(>kIdleOp{ + what: f, + done: done, + }) + <-done + close(done) } - return true // don't destroy the callback - }) + }() go func() { main() |
