Created
July 11, 2011 04:02
-
-
Save jessta/1075298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
process := make(chan *feat.Feature) | |
buffer := make(chan *feat.Feature, 1000) | |
wg := new(sync.WaitGroup) | |
if *cores < 2 { | |
*cores = 2 | |
} | |
for i := 0; i < *cores-1; i++ { | |
go func(){wg.Add(1); processServer(intervalTree, process, buffer); wg.Done()} | |
} | |
//output server | |
go func() { | |
wg.Add(1) | |
for feature := range buffer { | |
out.Write(feature) | |
} | |
wg.Done() | |
}() | |
for { | |
if feature, err := target.Read(); err == nil { | |
process <- feature | |
} else { | |
close(process) | |
time.Sleep(1e8) | |
break | |
} | |
} | |
for len(buffer) > 0 { | |
time.Sleep(1e8) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment