Skip to content

Commit

Permalink
KTOR-3422 Upgrade kotlin to 1.6.0 (#2693)
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l committed Nov 25, 2021
1 parent 5510f8e commit e8531a1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 46 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ org.gradle.vfs.watch=true
org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# kotlin
kotlin_version=1.5.31
kotlin_version=1.6.0
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.stability.nowarn=true

# kotlin libraries
serialization_version=1.3.0
coroutines_version=1.5.2-native-mt
atomicfu_version=0.16.3
atomicfu_version=0.17.0
validator_version=0.3.0
kotlinx_html_version=0.7.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public actual interface WebSocketSession : CoroutineScope {
* raw websocket session.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public suspend fun send(frame: Frame) {
public actual suspend fun send(frame: Frame) {
outgoing.send(frame)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public actual interface WebSocketSession : CoroutineScope {
* raw websocket session.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public suspend fun send(frame: Frame) {
public actual suspend fun send(frame: Frame) {
outgoing.send(frame)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public actual interface WebSocketSession : CoroutineScope {
* raw websocket session.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public suspend fun send(frame: Frame) {
public actual suspend fun send(frame: Frame) {
outgoing.send(frame)
}

Expand Down
13 changes: 0 additions & 13 deletions ktor-io/common/src/io/ktor/utils/io/core/internal/Unsafe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ import kotlin.native.concurrent.*
@Experimental(level = Experimental.Level.ERROR)
public annotation class DangerousInternalIoApi

@DangerousInternalIoApi
public fun ByteReadPacket.`$unsafeAppend$`(builder: BytePacketBuilder) {
val builderHead = builder.stealAll() ?: return
val builderSize = builder.size

if (builderSize <= PACKET_MAX_COPY_SIZE && builderHead.next == null && tryWriteAppend(builderHead)) {
builder.afterBytesStolen()
return
}

append(builderHead)
}

internal fun ByteReadPacket.unsafeAppend(builder: BytePacketBuilder): Int {
val builderSize = builder.size
val builderHead = builder.stealAll() ?: return 0
Expand Down
30 changes: 17 additions & 13 deletions ktor-io/jvm/src/io/ktor/utils/io/ByteBufferChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2362,25 +2362,29 @@ internal open class ByteBufferChannel(
private suspend fun writeSuspend(size: Int) {
while (writeSuspendPredicate(size)) {
suspendCancellableCoroutine<Unit> { c ->
do {
closed?.sendException?.let { rethrowClosed(it) }
if (!writeSuspendPredicate(size)) {
c.resume(Unit)
break
}
} while (!setContinuation({ writeOp }, _writeOp, c, { writeSuspendPredicate(size) }))

flushImpl(minWriteSize = size)

if (shouldResumeReadOp()) {
resumeReadOp()
}
writeSuspend(size, c)
}
}

closed?.sendException?.let { rethrowClosed(it) }
}

private fun writeSuspend(size: Int, c: CancellableContinuation<Unit>) {
do {
closed?.sendException?.let { rethrowClosed(it) }
if (!writeSuspendPredicate(size)) {
c.resume(Unit)
break
}
} while (!setContinuation({ writeOp }, _writeOp, c, { writeSuspendPredicate(size) }))

flushImpl(minWriteSize = size)

if (shouldResumeReadOp()) {
resumeReadOp()
}
}

private inline fun <T, C : Continuation<T>> setContinuation(
getter: () -> C?,
updater: AtomicRef<C?>,
Expand Down
34 changes: 19 additions & 15 deletions ktor-io/jvm/src/io/ktor/utils/io/jvm/javaio/Blocking.kt
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,29 @@ private abstract class BlockingAdapter(val parent: Job? = null) {
result.value = rc

return suspendCoroutineUninterceptedOrReturn { ucont ->
var thread: Thread? = null

state.update { value ->
when (value) {
is Thread -> {
thread = value
ucont.intercepted()
}
this -> ucont.intercepted()
else -> throw IllegalStateException("Already suspended or in finished state")
}
}
rendezvous(ucont)
}
}

private fun rendezvous(ucont: Continuation<Any>): Any {
var thread: Thread? = null

if (thread != null) {
parkingImpl.unpark(thread!!)
state.update { value ->
when (value) {
is Thread -> {
thread = value
ucont.intercepted()
}
this -> ucont.intercepted()
else -> throw IllegalStateException("Already suspended or in finished state")
}
}

COROUTINE_SUSPENDED
if (thread != null) {
parkingImpl.unpark(thread!!)
}

return COROUTINE_SUSPENDED
}

protected fun finish(rc: Int) {
Expand Down

0 comments on commit e8531a1

Please sign in to comment.