summaryrefslogtreecommitdiff
path: root/uitask.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-01 11:55:11 -0400
committerPietro Gagliardi <[email protected]>2014-07-01 11:55:57 -0400
commit607e710459a98a9c2f8c40bea85908e643a5fef6 (patch)
treedf8a1f1e31db74f1e0a12e9ed103f8ea7b5cbdc2 /uitask.go
parentad2c8d90334ffa74a6a81308502bbeb9717c060d (diff)
Restructured uitask to accept a limited range of actions. Implemented this on the Windows backend.
Diffstat (limited to 'uitask.go')
-rw-r--r--uitask.go27
1 files changed, 11 insertions, 16 deletions
diff --git a/uitask.go b/uitask.go
index 72f24ef..34d0dd1 100644
--- a/uitask.go
+++ b/uitask.go
@@ -36,19 +36,14 @@ var Ready = make(chan struct{})
// Do not pulse Stop more than once.
var Stop = make(chan struct{})
-// This function is a simple helper functionn that basically pushes the effect of a function call for later. This allows the selected safe Window methods to be safe.
-// TODO make sure this acts sanely if called from uitask itself
-func touitask(f func()) {
- done := make(chan struct{})
- defer close(done)
- go func() { // to avoid locking uitask itself
- done2 := make(chan struct{}) // make the chain uitask <- f <- uitask to avoid deadlocks
- defer close(done2)
- uitask <- func() {
- f()
- done2 <- struct{}{}
- }
- done <- <-done2
- }()
- <-done
-}
+// uitask is an object of a type implemented by each uitask_***.go that does everything that needs to be communicated to the main thread.
+type _uitask struct{}
+var uitask = _uitask{}
+
+// and the required methods are:
+var xuitask interface {
+ // creates a window
+ // TODO whether this waits for the window creation to finish is implementation defined?
+ createWindow(*Window, Control, bool)
+} = uitask
+// compilation will fail if uitask doesn't have all these methods