Added a meaningful comment to the method of the base tile creator which creates the backgound task.

This commit is contained in:
Sascha L. Teichmann 2017-04-15 13:08:19 +02:00
parent 6a1356f0eb
commit 8badf4aaca

View File

@ -52,14 +52,13 @@ var BackgroundColor = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
type BaseTileUpdateFunc func(x, y int, hash []byte) bool
type BaseTileCreator struct {
client *RedisClient
colors *Colors
renderer *Renderer
yOrder *YOrder
yMin int16
yMax int16
baseDir string
//update BaseTileUpdateFunc
client *RedisClient
colors *Colors
renderer *Renderer
yOrder *YOrder
yMin int16
yMax int16
baseDir string
emptyImage []byte
bg color.RGBA
}
@ -71,7 +70,7 @@ func NewBaseTileCreator(
yMin, yMax int16,
transparent bool,
baseDir string) *BaseTileCreator {
//update BaseTileUpdateFunc) *BaseTileCreator {
renderer := NewRenderer(tileWidth, tileHeight, transparent)
yMin, yMax = Order16(yMin, yMax)
btc := &BaseTileCreator{
@ -83,7 +82,6 @@ func NewBaseTileCreator(
yMax: yMax,
baseDir: baseDir,
}
//update: update}
btc.yOrder = NewYOrder(btc.renderBlock, yOrderCapacity)
return btc
}
@ -168,6 +166,9 @@ func (btc *BaseTileCreator) blankImage() []byte {
return btc.emptyImage
}
// WriteFunc returns a function intended to be run in background so
// the creation of the next tile with this creator can be done
// concurrently.
func (btc *BaseTileCreator) WriteFunc(i, j int, update BaseTileUpdateFunc) func() (bool, error) {
path := filepath.Join(btc.baseDir, strconv.Itoa(i), strconv.Itoa(j)+".png")