Kotlin 2.2.20-Beta1 and remove custom impl
This commit is contained in:
1 parent
c6f7d9d869
commit
c57a4e4132
4 files changed
+5
-32
No files matched your search
@@ -284,6 +284,7 @@ kotlin {
|
||||
)
|
||||
freeCompilerArgs.addAll(
|
||||
"-Xcontext-parameters",
|
||||
"-Xwhen-expressions=indy",
|
||||
"-Xannotation-default-target=param-property",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -50,19 +50,19 @@ import com.hippo.ehviewer.ktbuilder.execute
|
||||
import com.hippo.ehviewer.ktbuilder.imageRequest
|
||||
import com.hippo.ehviewer.util.isAtLeastP
|
||||
import com.hippo.ehviewer.util.isAtLeastU
|
||||
import com.hippo.ehviewer.util.updateAndGet
|
||||
import com.hippo.files.openFileDescriptor
|
||||
import com.hippo.files.toUri
|
||||
import java.nio.ByteBuffer
|
||||
import kotlin.concurrent.atomics.AtomicInt
|
||||
import kotlin.concurrent.atomics.decrementAndFetch
|
||||
import kotlin.concurrent.atomics.updateAndFetch
|
||||
import okio.Path
|
||||
import splitties.init.appCtx
|
||||
|
||||
class Image private constructor(image: CoilImage, private val src: ImageSource) {
|
||||
val refcnt = AtomicInt(1)
|
||||
|
||||
fun pin() = refcnt.updateAndGet { if (it != 0) it + 1 else 0 } != 0
|
||||
fun pin() = refcnt.updateAndFetch { if (it != 0) it + 1 else 0 } != 0
|
||||
|
||||
fun unpin() = (refcnt.decrementAndFetch() == 0).also { if (it) recycle() }
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.hippo.ehviewer.util
|
||||
|
||||
import kotlin.concurrent.atomics.AtomicInt
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
inline fun AtomicInt.loop(action: (Int) -> Unit): Nothing {
|
||||
contract { callsInPlace(action, InvocationKind.AT_LEAST_ONCE) }
|
||||
do {
|
||||
action(load())
|
||||
} while (true)
|
||||
}
|
||||
|
||||
inline fun <R> AtomicInt.update(function: (Int) -> Int, transform: (old: Int, new: Int) -> R): R {
|
||||
contract {
|
||||
callsInPlace(function, InvocationKind.AT_LEAST_ONCE)
|
||||
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
|
||||
}
|
||||
loop { cur ->
|
||||
val upd = function(cur)
|
||||
if (compareAndSet(cur, upd)) return transform(cur, upd)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun AtomicInt.updateAndGet(function: (Int) -> Int): Int {
|
||||
contract { callsInPlace(function, InvocationKind.AT_LEAST_ONCE) }
|
||||
return update(function) { _, new -> new }
|
||||
}
|
||||
@@ -18,11 +18,11 @@ coil = "3.3.0"
|
||||
compose-bom = "2025.07.00"
|
||||
compose-destinations = "2.2.0"
|
||||
compose-preference = "2.1.0"
|
||||
kotlin = "2.2.0"
|
||||
kotlin = "2.2.20-Beta1"
|
||||
kotlinx-coroutines = "1.10.2"
|
||||
kotlinx-datetime = "0.7.1"
|
||||
kotlinx-serialization = "1.9.0"
|
||||
ksp = "2.2.0-2.0.2"
|
||||
ksp = "2.2.20-Beta1-2.0.2"
|
||||
ktor = "3.2.2"
|
||||
okhttp = "5.1.0"
|
||||
okio = "3.15.0"
|
||||
|
||||
Reference in new issue
Block a user