getProfile synchronized

This commit is contained in:
Milos Kozak 2021-06-23 21:01:10 +02:00
parent d0365afe89
commit e06ec0eba1

View file

@ -67,14 +67,15 @@ class ProfileFunctionImplementation @Inject constructor(
override fun getProfile(): Profile? =
getProfile(dateUtil.now())
@Synchronized
override fun getProfile(time: Long): Profile? {
val rounded = time - time % 1000
val cached = cache[rounded]
if (cached != null) {
// aapsLogger.debug("XXXXXXXXXXXXXXX HIT getProfile for $time $rounded")
// aapsLogger.debug("HIT getProfile for $time $rounded")
return cached
}
// aapsLogger.debug("XXXXXXXXXXXXXXX getProfile called for $time")
// aapsLogger.debug("getProfile called for $time")
val ps = repository.getEffectiveProfileSwitchActiveAt(time).blockingGet()
if (ps is ValueWrapper.Existing) {
val sealed = ProfileSealed.EPS(ps.value)