package eu.friedcutlet.yokan.app.profiles import eu.friedcutlet.yokan.util.PlatformLock import eu.friedcutlet.yokan.domain.ProfileId // Foreground scenes and BGTasks share the app process. App extensions cannot mutate profile data. private val reservationLock = PlatformLock() private val reservations = mutableSetOf() internal actual suspend fun acquireProfileStorageLease(id: ProfileId): ProfileStorageLease { if (id == ProfileId.Default) return ProfileStorageLease {} reservationLock.withLock { check(reservations.add(id)) { "Profile is already open" } } return ProfileStorageLease { reservationLock.withLock { reservations.remove(id) } } }