Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class kotlinx/coroutines/CancellableContinuation$DefaultImpls {
public static synthetic fun tryResume$default (Lkotlinx/coroutines/CancellableContinuation;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;
}

public class kotlinx/coroutines/CancellableContinuationImpl : kotlinx/coroutines/DispatchedTask, kotlin/coroutines/jvm/internal/CoroutineStackFrame, kotlinx/coroutines/CancellableContinuation, kotlinx/coroutines/Waiter {
public class kotlinx/coroutines/CancellableContinuationImpl : kotlin/coroutines/jvm/internal/CoroutineStackFrame, kotlinx/coroutines/CancellableContinuation, kotlinx/coroutines/Waiter {
public fun <init> (Lkotlin/coroutines/Continuation;I)V
public final fun callCancelHandler (Lkotlinx/coroutines/CancelHandler;Ljava/lang/Throwable;)V
public final fun callOnCancellation (Lkotlin/jvm/functions/Function1;Ljava/lang/Throwable;)V
Expand Down Expand Up @@ -84,12 +84,6 @@ public final class kotlinx/coroutines/CancellableContinuationKt {
public static final fun suspendCancellableCoroutine (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class kotlinx/coroutines/ChildContinuation {
public final field child Lkotlinx/coroutines/CancellableContinuationImpl;
public fun <init> (Lkotlinx/coroutines/CancellableContinuationImpl;)V
public fun invoke (Ljava/lang/Throwable;)V
}

public abstract interface class kotlinx/coroutines/ChildHandle : kotlinx/coroutines/DisposableHandle {
public abstract fun childCancelled (Ljava/lang/Throwable;)Z
public abstract fun getParent ()Lkotlinx/coroutines/Job;
Expand Down Expand Up @@ -318,15 +312,6 @@ public final class kotlinx/coroutines/DelayKt {
public abstract interface annotation class kotlinx/coroutines/DelicateCoroutinesApi : java/lang/annotation/Annotation {
}

public final class kotlinx/coroutines/DispatchedCoroutine {
public static final synthetic fun get_decision$volatile$FU$kotlinx_coroutines_core ()Ljava/util/concurrent/atomic/AtomicIntegerFieldUpdater;
}

public abstract class kotlinx/coroutines/DispatchedTask : kotlinx/coroutines/scheduling/Task {
public field resumeMode I
public final fun run ()V
}

public final class kotlinx/coroutines/DispatchedTaskKt {
public static final field MODE_CANCELLABLE I
}
Expand Down Expand Up @@ -970,12 +955,6 @@ public final class kotlinx/coroutines/debug/internal/DebuggerInfo : java/io/Seri
public final fun getState ()Ljava/lang/String;
}

public final class kotlinx/coroutines/debug/internal/StackTraceFrame : kotlin/coroutines/jvm/internal/CoroutineStackFrame {
public final field stackTraceElement Ljava/lang/StackTraceElement;
public fun getCallerFrame ()Lkotlin/coroutines/jvm/internal/CoroutineStackFrame;
public fun getStackTraceElement ()Ljava/lang/StackTraceElement;
}

public abstract class kotlinx/coroutines/flow/AbstractFlow : kotlinx/coroutines/flow/CancellableFlow, kotlinx/coroutines/flow/Flow {
public fun <init> ()V
public final fun collect (Lkotlinx/coroutines/flow/FlowCollector;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -1287,10 +1266,6 @@ public class kotlinx/coroutines/scheduling/ExperimentalCoroutineDispatcher : kot
public fun toString ()Ljava/lang/String;
}

public abstract class kotlinx/coroutines/scheduling/Task : java/lang/Runnable {
public field submissionTime J
}

public final class kotlinx/coroutines/selects/OnTimeoutKt {
public static final fun onTimeout (Lkotlinx/coroutines/selects/SelectBuilder;JLkotlin/jvm/functions/Function1;)V
public static final fun onTimeout-8Mi8wO0 (Lkotlinx/coroutines/selects/SelectBuilder;JLkotlin/jvm/functions/Function1;)V
Expand Down
7 changes: 2 additions & 5 deletions kotlinx-coroutines-core/common/src/Builders.common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,13 @@ private const val SUSPENDED = 1
private const val RESUMED = 2

// Used by withContext when context dispatcher changes
@PublishedApi
internal class DispatchedCoroutine<in T> internal constructor(
internal class DispatchedCoroutine<in T>(
context: CoroutineContext,
uCont: Continuation<T>
) : ScopeCoroutine<T>(context, uCont) {
// this is copy-and-paste of a decision state machine inside AbstractionContinuation
// todo: we may some-how abstract it via inline class
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField
public val _decision = atomic(UNDECIDED)
private val _decision = atomic(UNDECIDED)

private fun trySuspend(): Boolean {
_decision.loop { decision ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,12 @@ private data class CompletedContinuation(
onCancellation?.let { cont.callOnCancellation(it, cause) }
}
}

// Same as ChildHandleNode, but for cancellable continuation
private class ChildContinuation(
@JvmField val child: CancellableContinuationImpl<*>
) : JobCancellingNode() {
override fun invoke(cause: Throwable?) {
child.parentCancelled(child.getContinuationCancellationCause(job))
}
}
15 changes: 1 addition & 14 deletions kotlinx-coroutines-core/common/src/JobSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public open class JobSupport constructor(active: Boolean) : Job, ChildJob, Paren
*/

// Note: use shared objects while we have no listeners
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
private val _state = atomic<Any?>(if (active) EMPTY_ACTIVE else EMPTY_NEW)

private val _parentHandle = atomic<ChildHandle?>(null)
Expand Down Expand Up @@ -1439,22 +1438,10 @@ private class InvokeOnCancelling(
}
}

internal class ChildHandleNode(
private class ChildHandleNode(
@JvmField val childJob: ChildJob
) : JobCancellingNode(), ChildHandle {
override val parent: Job get() = job
override fun invoke(cause: Throwable?) = childJob.parentCancelled(job)
override fun childCancelled(cause: Throwable): Boolean = job.childCancelled(cause)
}

// Same as ChildHandleNode, but for cancellable continuation
@PublishedApi
internal class ChildContinuation(
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField val child: CancellableContinuationImpl<*>
) : JobCancellingNode() {
override fun invoke(cause: Throwable?) {
child.parentCancelled(child.getContinuationCancellationCause(job))
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ private val UNDEFINED = Symbol("UNDEFINED")
@JvmField
internal val REUSABLE_CLAIMED = Symbol("REUSABLE_CLAIMED")

@PublishedApi
internal class DispatchedContinuation<in T>(
@JvmField internal val dispatcher: CoroutineDispatcher,
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField val continuation: Continuation<T>
) : DispatchedTask<T>(MODE_UNINITIALIZED), CoroutineStackFrame, Continuation<T> by continuation {
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ internal const val MODE_UNINITIALIZED = -1
internal val Int.isCancellableMode get() = this == MODE_CANCELLABLE || this == MODE_CANCELLABLE_REUSABLE
internal val Int.isReusableMode get() = this == MODE_CANCELLABLE_REUSABLE

@PublishedApi
internal abstract class DispatchedTask<in T> internal constructor(
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField public var resumeMode: Int
@JvmField var resumeMode: Int
) : SchedulerTask() {
internal abstract val delegate: Continuation<T>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ internal class DebugCoroutineInfoImpl internal constructor(
*/
private val _context = WeakReference(context)
public val context: CoroutineContext? // can be null when the coroutine was already garbage-collected
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
get() = _context.get()

// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
public val creationStackTrace: List<StackTraceElement> get() = creationStackTrace()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import kotlin.coroutines.jvm.internal.*
/**
* A stack-trace represented as [CoroutineStackFrame].
*/
@PublishedApi
internal class StackTraceFrame internal constructor(
internal class StackTraceFrame(
override val callerFrame: CoroutineStackFrame?,
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField public val stackTraceElement: StackTraceElement
private val stackTraceElement: StackTraceElement
) : CoroutineStackFrame {
override fun getStackTraceElement(): StackTraceElement = stackTraceElement
}
7 changes: 2 additions & 5 deletions kotlinx-coroutines-core/jvm/src/scheduling/Tasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ internal val NonBlockingContext: TaskContext = TaskContextImpl(TASK_NON_BLOCKING
@JvmField
internal val BlockingContext: TaskContext = TaskContextImpl(TASK_PROBABLY_BLOCKING)

@PublishedApi
internal abstract class Task internal constructor(
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
internal abstract class Task(
@JvmField var submissionTime: Long,
// Used by the IDEA debugger via reflection and must be kept binary-compatible, see KTIJ-24102
@JvmField internal var taskContext: TaskContext
@JvmField var taskContext: TaskContext
) : Runnable {
internal constructor() : this(0, NonBlockingContext)
internal inline val mode: Int get() = taskContext.taskMode // TASK_XXX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ class ReusableCancellableContinuationTest : TestBase() {
for (value in channel) {
delay(1)
}
FieldWalker.assertReachableCount(1, coroutineContext[Job]) { it is ChildContinuation }
FieldWalker.assertReachableCount(1, coroutineContext[Job]) {
// could be `it is ChildContinuation` if `ChildContinuation` wasn't private
it::class.simpleName == "ChildContinuation"
}
}
}