enable concurrent writing explicitly
parent
a406864fd7
commit
af6510b008
|
@ -167,6 +167,7 @@ func Import() {
|
|||
relWriter := writer.NewRelationWriter(osmCache, diffCache, relations,
|
||||
db, progress, config.BaseOptions.Srid)
|
||||
relWriter.SetLimiter(geometryLimiter)
|
||||
relWriter.EnableConcurrent()
|
||||
relWriter.Start()
|
||||
relWriter.Wait() // blocks till the Relations.Iter() finishes
|
||||
osmCache.Relations.Close()
|
||||
|
@ -175,6 +176,7 @@ func Import() {
|
|||
wayWriter := writer.NewWayWriter(osmCache, diffCache, ways, db,
|
||||
progress, config.BaseOptions.Srid)
|
||||
wayWriter.SetLimiter(geometryLimiter)
|
||||
wayWriter.EnableConcurrent()
|
||||
wayWriter.Start()
|
||||
wayWriter.Wait() // blocks till the Ways.Iter() finishes
|
||||
osmCache.Ways.Close()
|
||||
|
@ -183,6 +185,7 @@ func Import() {
|
|||
nodeWriter := writer.NewNodeWriter(osmCache, nodes, db,
|
||||
progress, config.BaseOptions.Srid)
|
||||
nodeWriter.SetLimiter(geometryLimiter)
|
||||
nodeWriter.EnableConcurrent()
|
||||
nodeWriter.Start()
|
||||
nodeWriter.Wait() // blocks till the Nodes.Iter() finishes
|
||||
osmCache.Close()
|
||||
|
|
|
@ -28,14 +28,23 @@ type OsmElemWriter struct {
|
|||
writer looper
|
||||
srid int
|
||||
expireTiles *expire.Tiles
|
||||
concurrent bool
|
||||
}
|
||||
|
||||
func (writer *OsmElemWriter) SetLimiter(limiter *limit.Limiter) {
|
||||
writer.limiter = limiter
|
||||
}
|
||||
|
||||
func (writer *OsmElemWriter) EnableConcurrent() {
|
||||
writer.concurrent = true
|
||||
}
|
||||
|
||||
func (writer *OsmElemWriter) Start() {
|
||||
for i := 0; i < runtime.NumCPU(); i++ {
|
||||
concurrency := 1
|
||||
if writer.concurrent {
|
||||
concurrency = runtime.NumCPU()
|
||||
}
|
||||
for i := 0; i < concurrency; i++ {
|
||||
writer.wg.Add(1)
|
||||
go writer.writer.loop()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue