diff --git a/095-worker-pool/095-worker-pool.go b/095-worker-pool/095-worker-pool.go deleted file mode 100644 index f0a7018..0000000 --- a/095-worker-pool/095-worker-pool.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import "time" - -func main() { - jobs := make(chan int, 100) - acks := make(chan bool, 100) - - for w := 0; w < 10; w++ { - go func() { - for j := range jobs { - println("worker", w, "processing job", j) - time.Sleep(time.Millisecond * 150) - acks <- true - } - }() - } - - for j := 0; j < 100; j++ { - jobs <- j - } - - for a := 0; a < 100; a++ { - <- acks - } - println("all done") -} diff --git a/095-worker-pool/worker-pool.go b/095-worker-pool/worker-pool.go new file mode 100644 index 0000000..4d72646 --- /dev/null +++ b/095-worker-pool/worker-pool.go @@ -0,0 +1,31 @@ +// ## Worker Pool + +package main + +import "time" + +func main() { + jobs := make(chan int, 100) + acks := make(chan bool, 100) + + for w := 0; w < 10; w++ { + go func() { + for j := range jobs { + println("worker", w, "processing job", j) + time.Sleep(time.Millisecond * 150) + acks <- true + } + }() + } + + for j := 0; j < 100; j++ { + jobs <- j + } + + for a := 0; a < 100; a++ { + <-acks + } + println("all done") +} + +// todo: broken diff --git a/096-line-filter/lines b/096-line-filter/lines deleted file mode 100644 index 7e752bb..0000000 --- a/096-line-filter/lines +++ /dev/null @@ -1,2 +0,0 @@ -hello -filter