Skip to content

Commit

Permalink
Remove freeze usage (#1444)
Browse files Browse the repository at this point in the history
The old memory model was removed in 1.9.20.
  • Loading branch information
JakeWharton authored Sep 25, 2024
1 parent c0fe9ff commit 2a756ad
Showing 1 changed file with 1 addition and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package app.cash.zipline.loader

import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.concurrent.freeze
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.suspendCancellableCoroutine
import okio.ByteString
Expand All @@ -37,10 +35,6 @@ import platform.Foundation.dataTaskWithRequest
internal class URLSessionZiplineHttpClient(
private val urlSession: NSURLSession,
) : ZiplineHttpClient() {
init {
maybeFreeze()
}

override suspend fun download(
url: String,
requestHeaders: List<Pair<String, String>>,
Expand All @@ -55,7 +49,7 @@ internal class URLSessionZiplineHttpClient(
addValue(value = value, forHTTPHeaderField = name)
}
},
completionHandler = completionHandler::invoke.maybeFreeze(),
completionHandler = completionHandler::invoke,
)

continuation.invokeOnCancellation {
Expand Down Expand Up @@ -92,13 +86,3 @@ private class CompletionHandler(
continuation.resume(data.toByteString())
}
}

/** Freeze this when executing on Kotlin/Native's strict memory model. */
@OptIn(ExperimentalNativeApi::class)
private fun <T> T.maybeFreeze(): T {
return if (Platform.memoryModel == MemoryModel.STRICT) {
this.freeze()
} else {
this
}
}

0 comments on commit 2a756ad

Please sign in to comment.