Skip to content

Instantly share code, notes, and snippets.

@kortschak
Created August 17, 2011 06:40
Show Gist options
  • Save kortschak/1150943 to your computer and use it in GitHub Desktop.
Save kortschak/1150943 to your computer and use it in GitHub Desktop.
{
// preprocessing
dp := make(chan *DP, self.cores)
for i := 0; i < self.cores; i++ {
dp <- &DP{
a: self.a,
b: self.b,
minLen: minLen,
maxDiff: maxDiff,
segSols: tSegSols,
comp: self.comp,
}
}
wg := &sync.WaitGroup{}
for i, z := range trapezoids {
if !covered[i] {
if z.Top-z.Bot < self.k {
continue
}
// We cannot use a single []DPHit for AlignTraps as the DPs will clobber each other.
// So we get each job to slot results into a [][]DPHit. Probably a nicer way to do this.
wg.Add(1)
go func(p *DP, i int) {
defer func() {
dp <- p
wg.Done()
}()
p.trapezoids = trapezoids[i+1:]
p.slot = i // index of [][]DPHit to write into
p.alignRecursion(trapezoids[i])
}(<-dp, i)
}
}
//wait for alignments to finish
wg.Wait()
// more processing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment