Exemplo n.º 1
0
func (qt *QuadTreeDef) SaveToNoms(vw types.ValueWriter, start time.Time, quiet bool) *SQuadTree {
	wChan := make(chan *SQuadTree, 1024)
	var wg sync.WaitGroup
	for i := 0; i < 32; i++ {
		wg.Add(1)
		go func() {
			for sqt := range wChan {
				vw.WriteValue(*sqt)
			}
			wg.Done()
		}()
	}

	if util.MaybeStartCPUProfile() {
		defer util.StopCPUProfile()
	}

	sqt := qt.saveNodeToNoms(wChan, vw, start, quiet)
	close(wChan)
	wg.Wait()
	return sqt
}
Exemplo n.º 2
0
func getNomsWriter(vw types.ValueWriter) (iChan chan incidentWithIndex, rChan chan refIndex) {
	iChan = make(chan incidentWithIndex, 3000)
	rChan = make(chan refIndex, 3000)
	var wg sync.WaitGroup
	for i := 0; i < 32; i++ {
		wg.Add(1)
		go func() {
			for incidentRecord := range iChan {
				v := incidentRecord.incident.New()
				rChan <- refIndex{vw.WriteValue(v), incidentRecord.index}
			}
			wg.Done()
		}()
	}

	go func() {
		wg.Wait()
		close(rChan)
	}()

	return
}