Initial commit

This commit is contained in:
2014-08-24 19:56:55 +07:00
commit 509f281f72
11 changed files with 337 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package tools
import (
"code.google.com/p/go.net/context"
)
func SyncronizeParallelChain(ctx context.Context, fn func(context.Context)) {
var (
pcontexts = ctx.Value("parallel_contexts").(chan context.Context)
pfinished = ctx.Value("parallel_finished").(chan struct{})
working = true
)
for len(pcontexts) > 0 || working {
select {
case pctx := <-pcontexts:
fn(pctx)
case <-pfinished:
working = false
}
}
}