imposm3/writer/writer.go

51 lines
888 B
Go
Raw Normal View History

2013-05-14 18:15:35 +04:00
package writer
import (
2013-08-29 17:44:15 +04:00
"imposm3/cache"
"imposm3/database"
"imposm3/expire"
"imposm3/geom/limit"
"imposm3/stats"
2013-05-21 09:52:03 +04:00
"runtime"
"sync"
2013-05-14 18:15:35 +04:00
)
type ErrorLevel interface {
Level() int
}
2013-05-28 14:54:19 +04:00
type looper interface {
loop()
}
type OsmElemWriter struct {
2013-10-28 11:26:51 +04:00
osmCache *cache.OSMCache
diffCache *cache.DiffCache
progress *stats.Statistics
inserter database.Inserter
wg *sync.WaitGroup
limiter *limit.Limiter
writer looper
srid int
expireTiles *expire.Tiles
2013-05-28 14:54:19 +04:00
}
2013-07-30 10:17:47 +04:00
func (writer *OsmElemWriter) SetLimiter(limiter *limit.Limiter) {
writer.limiter = limiter
2013-05-28 14:54:19 +04:00
}
func (writer *OsmElemWriter) Start() {
for i := 0; i < runtime.NumCPU(); i++ {
writer.wg.Add(1)
go writer.writer.loop()
}
}
2013-07-12 16:57:06 +04:00
func (writer *OsmElemWriter) SetExpireTiles(expireTiles *expire.Tiles) {
writer.expireTiles = expireTiles
}
2013-05-28 14:54:19 +04:00
func (writer *OsmElemWriter) Close() {
writer.wg.Wait()
}