mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 08:40:18 +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) {
|
||||
|
||||
type jobWriter struct {
|
||||
job *xzc
|
||||
wFn func() (bool, error)
|
||||
canceled *bool
|
||||
wFn func() (bool, error)
|
||||
}
|
||||
|
||||
jWs := make(chan jobWriter)
|
||||
|
||||
asyncWrite := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
defer close(asyncWrite)
|
||||
|
||||
for jw := range jWs {
|
||||
updated, err := jw.wFn()
|
||||
if err != nil {
|
||||
*jw.canceled = true
|
||||
log.Printf("WARN: writing tile failed: %v.\n", err)
|
||||
}
|
||||
if !updated {
|
||||
jw.job.canceled = true
|
||||
*jw.canceled = true
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
close(jWs)
|
||||
btc.Close()
|
||||
done.Done()
|
||||
}()
|
||||
@ -431,6 +435,13 @@ func (tu *tileUpdater) updateBaseTiles(
|
||||
job.canceled = true
|
||||
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