Skip to content
Browse files

added drw and ex1

Signed-off-by: Tim Henderson <tim.tadh@gmail.com>
  • Loading branch information...
1 parent 0fed9df commit 03f45bf99985946064f5b3f205fa077d7adf9d6e @timtadh committed Feb 10, 2010
Showing with 73 additions and 0 deletions.
  1. +24 −0 drw/drw.go
  2. +9 −0 drw/run
  3. +13 −0 ex1/Makefile
  4. BIN ex1/main
  5. +27 −0 ex1/main.go
View
24 drw/drw.go
@@ -0,0 +1,24 @@
+package main;
+import "exp/draw/x11";
+import "fmt";
+//import "time";
+//import "exp/draw";
+//import "os";
+
+func init(){
+ return;
+}
+
+func main() {
+ //var x draw.Context;
+ //var y os.Error;
+ x, y := x11.NewWindow();
+ if (y != nil) { fmt.Println("error"); }
+ if (x == nil) { fmt.Println("error"); }
+ fmt.Println("hello");
+ for i := 0; i < 1000000000 ; i++ {
+ fmt.Print("x");
+ }
+}
+
+
View
9 drw/run
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+rm *.6
+rm 6.out
+
+6g *.go
+6l *.6
+./6.out
+
View
13 ex1/Makefile
@@ -0,0 +1,13 @@
+
+
+main:
+ 6g -o main.6 main.go
+build: main
+ 6l -o main main.6
+run: build
+ ./main
+
+.PHONY : clean
+clean :
+ -rm main *.6
+ ls
View
BIN ex1/main
Binary file not shown.
View
27 ex1/main.go
@@ -0,0 +1,27 @@
+package main
+
+import "fmt"
+
+func main() {
+ // yield and results are the same channel.
+ results := make(chan int)
+
+ // ack acknowledge reciept and processing of last result
+ ack := make(chan bool)
+
+ // Caculating function
+ go func(yield chan<- int, ack <-chan bool) {
+
+ for i := 0; i < 10; i++ {
+ yield<-i
+ <-ack
+ }
+ close(yield) // causes the processing loop to quit
+ }(results, ack)
+
+ // Processing Loop
+ for result := range results {
+ fmt.Println(result);
+ ack<-true; // ack<-true must be the last line of the loop.
+ }
+}

0 comments on commit 03f45bf

Please sign in to comment.
Something went wrong with that request. Please try again.