mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 01:10:17 +01:00
Wait until all tiles are written out or are cancelled.
This commit is contained in:
parent
c507663826
commit
da2b327985
@ -400,26 +400,30 @@ func (tu *tileUpdater) updateBaseTiles(
|
|||||||
update common.BaseTileUpdateFunc) {
|
update common.BaseTileUpdateFunc) {
|
||||||
|
|
||||||
type jobWriter struct {
|
type jobWriter struct {
|
||||||
job *xzc
|
canceled *bool
|
||||||
wFn func() (bool, error)
|
wFn func() (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
jWs := make(chan jobWriter)
|
jWs := make(chan jobWriter)
|
||||||
|
|
||||||
|
asyncWrite := make(chan struct{})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
defer close(asyncWrite)
|
||||||
|
|
||||||
for jw := range jWs {
|
for jw := range jWs {
|
||||||
updated, err := jw.wFn()
|
updated, err := jw.wFn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
*jw.canceled = true
|
||||||
log.Printf("WARN: writing tile failed: %v.\n", err)
|
log.Printf("WARN: writing tile failed: %v.\n", err)
|
||||||
}
|
}
|
||||||
if !updated {
|
if !updated {
|
||||||
jw.job.canceled = true
|
*jw.canceled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
close(jWs)
|
|
||||||
btc.Close()
|
btc.Close()
|
||||||
done.Done()
|
done.Done()
|
||||||
}()
|
}()
|
||||||
@ -431,6 +435,13 @@ func (tu *tileUpdater) updateBaseTiles(
|
|||||||
job.canceled = true
|
job.canceled = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
jWs <- jobWriter{job, btc.WriteFunc(int(job.X), int(job.Z), update)}
|
jWs <- jobWriter{
|
||||||
|
&job.canceled,
|
||||||
|
btc.WriteFunc(int(job.X), int(job.Z), update),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(jWs)
|
||||||
|
// Wait until all tiles are written.
|
||||||
|
<-asyncWrite
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user