File tree 4 files changed +15
-1
lines changed
4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ public final class kotlinx/coroutines/CancellableContinuationKt {
86
86
87
87
public abstract interface class kotlinx/coroutines/ChildHandle : kotlinx/coroutines/DisposableHandle {
88
88
public abstract fun childCancelled (Ljava/lang/Throwable;)Z
89
+ public abstract fun getParent ()Lkotlinx/coroutines/Job;
89
90
}
90
91
91
92
public abstract interface class kotlinx/coroutines/ChildJob : kotlinx/coroutines/Job {
@@ -471,6 +472,7 @@ public final class kotlinx/coroutines/NonDisposableHandle : kotlinx/coroutines/C
471
472
public static final field INSTANCE Lkotlinx/coroutines/NonDisposableHandle;
472
473
public fun childCancelled (Ljava/lang/Throwable;)Z
473
474
public fun dispose ()V
475
+ public fun getParent ()Lkotlinx/coroutines/Job;
474
476
public fun toString ()Ljava/lang/String;
475
477
}
476
478
Original file line number Diff line number Diff line change @@ -466,6 +466,14 @@ public interface ParentJob : Job {
466
466
@InternalCoroutinesApi
467
467
@Deprecated(level = DeprecationLevel .ERROR , message = " This is internal API and may be removed in the future releases" )
468
468
public interface ChildHandle : DisposableHandle {
469
+
470
+ /* *
471
+ * Returns the parent of the current parent-child relationship.
472
+ * @suppress **This is unstable API and it is subject to change.**
473
+ */
474
+ @InternalCoroutinesApi
475
+ public val parent: Job ?
476
+
469
477
/* *
470
478
* Child is cancelling its parent by invoking this method.
471
479
* This method is invoked by the child twice. The first time child report its root cause as soon as possible,
@@ -659,6 +667,9 @@ private fun Throwable?.orCancellation(job: Job): Throwable = this ?: JobCancella
659
667
*/
660
668
@InternalCoroutinesApi
661
669
public object NonDisposableHandle : DisposableHandle, ChildHandle {
670
+
671
+ override val parent: Job ? get() = null
672
+
662
673
/* *
663
674
* Does not do anything.
664
675
* @suppress
Original file line number Diff line number Diff line change @@ -1459,6 +1459,7 @@ private class InvokeOnCancelling(
1459
1459
internal class ChildHandleNode (
1460
1460
@JvmField val childJob : ChildJob
1461
1461
) : JobCancellingNode(), ChildHandle {
1462
+ override val parent: Job get() = job
1462
1463
override fun invoke (cause : Throwable ? ) = childJob.parentCancelled(job)
1463
1464
override fun childCancelled (cause : Throwable ): Boolean = job.childCancelled(cause)
1464
1465
}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ internal open class ScopeCoroutine<in T>(
21
21
final override fun getStackTraceElement (): StackTraceElement ? = null
22
22
23
23
final override val isScopedCoroutine: Boolean get() = true
24
- internal val parent: Job ? = context[ Job ]
24
+ internal val parent: Job ? get() = parentHandle?.parent
25
25
26
26
override fun afterCompletion (state : Any? ) {
27
27
// Resume in a cancellable way by default when resuming from another context
You can’t perform that action at this time.
0 commit comments