File tree Expand file tree Collapse file tree 6 files changed +28
-6
lines changed
common/kotlinx-coroutines-core-common/src
core/kotlinx-coroutines-core/src
js/kotlinx-coroutines-core-js/src
native/kotlinx-coroutines-core-native/src Expand file tree Collapse file tree 6 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ internal interface DispatchedTask<in T> : SchedulerTask {
218
218
(state as ? CompletedExceptionally )?.cause
219
219
220
220
public override fun run () {
221
+ val taskContext = this .taskContext
221
222
try {
222
223
val delegate = delegate as DispatchedContinuation <T >
223
224
val continuation = delegate.continuation
@@ -238,7 +239,7 @@ internal interface DispatchedTask<in T> : SchedulerTask {
238
239
} catch (e: Throwable ) {
239
240
throw DispatchException (" Unexpected exception running $this " , e)
240
241
} finally {
241
- afterTask()
242
+ afterTask(taskContext )
242
243
}
243
244
}
244
245
}
Original file line number Diff line number Diff line change @@ -8,4 +8,8 @@ internal expect interface SchedulerTask : Runnable
8
8
9
9
internal expect abstract class SchedulerTaskBase () : SchedulerTask
10
10
11
- internal expect inline fun SchedulerTask.afterTask ()
11
+ internal expect interface SchedulerTaskContext
12
+
13
+ internal expect val SchedulerTask .taskContext: SchedulerTaskContext
14
+
15
+ internal expect inline fun SchedulerTask.afterTask (taskContext : SchedulerTaskContext )
Original file line number Diff line number Diff line change @@ -13,5 +13,11 @@ internal actual abstract class SchedulerTaskBase actual constructor() : Schedule
13
13
override var taskContext: TaskContext = NonBlockingContext
14
14
}
15
15
16
+ internal actual typealias SchedulerTaskContext = TaskContext
17
+
18
+ @Suppress(" EXTENSION_SHADOWED_BY_MEMBER" )
19
+ internal actual val SchedulerTask .taskContext: SchedulerTaskContext get() = taskContext
20
+
16
21
@Suppress(" NOTHING_TO_INLINE" )
17
- internal actual inline fun SchedulerTask.afterTask () = taskContext.afterTask()
22
+ internal actual inline fun SchedulerTask.afterTask (taskContext : SchedulerTaskContext ) =
23
+ taskContext.afterTask()
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ internal interface Task : Runnable {
88
88
val mode: TaskMode get() = taskContext.taskMode
89
89
}
90
90
91
+ // Non-reusable Task implementation to wrap Runnable instances that do not otherwise implement task
91
92
internal class TaskImpl (
92
93
@JvmField val block : Runnable ,
93
94
override var submissionTime : Long ,
@@ -97,7 +98,7 @@ internal class TaskImpl(
97
98
try {
98
99
block.run ()
99
100
} finally {
100
- afterTask()
101
+ afterTask(taskContext )
101
102
}
102
103
}
103
104
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ internal actual typealias SchedulerTask = Runnable
9
9
10
10
internal actual abstract class SchedulerTaskBase actual constructor() : SchedulerTask
11
11
12
+ @Suppress(" ACTUAL_WITHOUT_EXPECT" )
13
+ internal actual typealias SchedulerTaskContext = Unit
14
+
15
+ internal actual val SchedulerTask .taskContext: SchedulerTaskContext get() = Unit
16
+
12
17
@Suppress(" NOTHING_TO_INLINE" )
13
- internal actual inline fun SchedulerTask.afterTask () {}
18
+ internal actual inline fun SchedulerTask.afterTask (taskContext : SchedulerTaskContext ) {}
14
19
Original file line number Diff line number Diff line change @@ -9,5 +9,10 @@ internal actual typealias SchedulerTask = Runnable
9
9
10
10
internal actual abstract class SchedulerTaskBase actual constructor() : SchedulerTask
11
11
12
+ @Suppress(" ACTUAL_WITHOUT_EXPECT" )
13
+ internal actual typealias SchedulerTaskContext = Unit
14
+
15
+ internal actual val SchedulerTask .taskContext: SchedulerTaskContext get() = kotlin.Unit
16
+
12
17
@Suppress(" NOTHING_TO_INLINE" )
13
- internal actual inline fun SchedulerTask.afterTask () {}
18
+ internal actual inline fun SchedulerTask.afterTask (taskContext : SchedulerTaskContext ) {}
You can’t perform that action at this time.
0 commit comments