mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
devicescale: Make DeviceScale concurrent-safe
This commit is contained in:
parent
d398cb14c2
commit
5a17497723
@ -14,12 +14,22 @@
|
|||||||
|
|
||||||
package devicescale
|
package devicescale
|
||||||
|
|
||||||
var scale = 0.0
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
scale = 0.0
|
||||||
|
m sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
func DeviceScale() float64 {
|
func DeviceScale() float64 {
|
||||||
if scale != 0.0 {
|
s := 0.0
|
||||||
return scale
|
m.Lock()
|
||||||
}
|
if scale == 0.0 {
|
||||||
scale = impl()
|
scale = impl()
|
||||||
return scale
|
}
|
||||||
|
s = scale
|
||||||
|
m.Unlock()
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user