summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-06 21:42:11 -0400
committerPietro Gagliardi <[email protected]>2014-07-06 21:42:11 -0400
commitfd183e8bf78b68c9007961de5c33f764758e0235 (patch)
tree8f1208d95ff7ee4f3193606f8f95e10498ec1716
parent65a3c67ebd7038f057142543e1c7a923910072e8 (diff)
Added the new common uitask code to the redo.
-rw-r--r--redo/uitask.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/redo/uitask.go b/redo/uitask.go
new file mode 100644
index 0000000..c29470a
--- /dev/null
+++ b/redo/uitask.go
@@ -0,0 +1,40 @@
+// 6 july 2014
+
+package ui
+
+// TODO Go, Start, Stop
+
+// This is the ui main loop.
+// It is spawned by Go as a goroutine.
+func uitask() {
+ for {
+ select {
+ case req := <-Do:
+ // TODO foreign event
+ issue(req)
+ case <-stall: // wait for event to finish
+ <-stall // see below for information
+ }
+ }
+}
+
+// At each event, this is pulsed twice: once when the event begins, and once when the event ends.
+// Do is not processed in between.
+var stall = make(chan struct{})
+
+// This is the common code for running an event.
+// TODO
+// - define event
+// - figure out how to return values from event handlers
+func doevent(e event) {
+ stall <- struct{}{} // enter event handler
+ c := make(Doer)
+ go func() {
+ e.do(c)
+ close(c)
+ }()
+ for req := range c {
+ issue(req)
+ }
+ stall <- struct{}{} // leave event handler
+}