ProfileStorageLease.ios.kt
composeApp/src/iosMain/kotlin/eu/friedcutlet/yokan/app/profiles/ProfileStorageLease.ios.kt
1package eu.friedcutlet.yokan.app.profiles23import eu.friedcutlet.yokan.util.PlatformLock4import eu.friedcutlet.yokan.domain.ProfileId56// Foreground scenes and BGTasks share the app process. App extensions cannot mutate profile data.7private val reservationLock = PlatformLock()8private val reservations = mutableSetOf<ProfileId>()9internal actual suspend fun acquireProfileStorageLease(id: ProfileId): ProfileStorageLease {10 if (id == ProfileId.Default) return ProfileStorageLease {}11 reservationLock.withLock { check(reservations.add(id)) { "Profile is already open" } }12 return ProfileStorageLease { reservationLock.withLock { reservations.remove(id) } }13}14