@@ -24,7 +24,6 @@ import kotlinx.coroutines.experimental.internal.OpDescriptor
24
24
import kotlinx.coroutines.experimental.internal.unwrap
25
25
import kotlinx.coroutines.experimental.intrinsics.startCoroutineUndispatched
26
26
import kotlinx.coroutines.experimental.selects.SelectClause0
27
- import kotlinx.coroutines.experimental.selects.SelectClause1
28
27
import kotlinx.coroutines.experimental.selects.SelectInstance
29
28
import kotlinx.coroutines.experimental.selects.select
30
29
import java.util.concurrent.Future
@@ -525,8 +524,8 @@ public actual object NonDisposableHandle : DisposableHandle {
525
524
* @param active when `true` the job is created in _active_ state, when `false` in _new_ state. See [Job] for details.
526
525
* @suppress **This is unstable API and it is subject to change.**
527
526
*/
528
- internal open class JobSupport (active : Boolean ) : Job, SelectClause0 {
529
- override val key: CoroutineContext .Key <* > get() = Job
527
+ internal actual open class JobSupport actual constructor (active : Boolean ) : Job, SelectClause0 {
528
+ actual final override val key: CoroutineContext .Key <* > get() = Job
530
529
531
530
/*
532
531
=== Internal states ===
@@ -598,7 +597,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
598
597
* It shall be invoked at most once after construction after all other initialization.
599
598
* @suppress **This is unstable API and it is subject to change.**
600
599
*/
601
- internal fun initParentJobInternal (parent : Job ? ) {
600
+ internal actual fun initParentJobInternal (parent : Job ? ) {
602
601
check(parentHandle == null )
603
602
if (parent == null ) {
604
603
parentHandle = NonDisposableHandle
@@ -637,14 +636,14 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
637
636
}
638
637
}
639
638
640
- public final override val isActive: Boolean get() {
639
+ public actual final override val isActive: Boolean get() {
641
640
val state = this .state
642
641
return state is Incomplete && state.isActive
643
642
}
644
643
645
- public final override val isCompleted: Boolean get() = state !is Incomplete
644
+ public actual final override val isCompleted: Boolean get() = state !is Incomplete
646
645
647
- public final override val isCancelled: Boolean get() {
646
+ public actual final override val isCancelled: Boolean get() {
648
647
val state = this .state
649
648
return state is Cancelled || (state is Finishing && state.cancelled != null )
650
649
}
@@ -741,7 +740,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
741
740
private fun notifyCancellation (list : NodeList , cause : Throwable ? ) =
742
741
notifyHandlers<JobCancellationNode <* >>(list, cause)
743
742
744
- public final override fun start (): Boolean {
743
+ public actual final override fun start (): Boolean {
745
744
loopOnState { state ->
746
745
when (startInternal(state)) {
747
746
FALSE -> return false
@@ -775,9 +774,9 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
775
774
* Override to provide the actual [start] action.
776
775
* This function is invoked exactly once when non-active coroutine is [started][start].
777
776
*/
778
- internal open fun onStartInternal () {}
777
+ internal actual open fun onStartInternal () {}
779
778
780
- public final override fun getCancellationException (): CancellationException {
779
+ public actual final override fun getCancellationException (): CancellationException {
781
780
val state = this .state
782
781
return when {
783
782
state is Finishing && state.cancelled != null ->
@@ -822,7 +821,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
822
821
public final override fun invokeOnCompletion (onCancelling_ : Boolean , handler : CompletionHandler ): DisposableHandle =
823
822
invokeOnCompletion(onCancelling = onCancelling_, invokeImmediately = true , handler = handler)
824
823
825
- public final override fun invokeOnCompletion (
824
+ public actual final override fun invokeOnCompletion (
826
825
onCancelling : Boolean ,
827
826
invokeImmediately : Boolean ,
828
827
handler : CompletionHandler
@@ -888,7 +887,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
888
887
_state .compareAndSet(state, list)
889
888
}
890
889
891
- public final override suspend fun join () {
890
+ public actual final override suspend fun join () {
892
891
if (! joinInternal()) { // fast-path no wait
893
892
return suspendCoroutineOrReturn { cont ->
894
893
cont.context.checkCompletion()
@@ -960,7 +959,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
960
959
*/
961
960
internal open val onCancelMode: Int get() = ON_CANCEL_MAKE_CANCELLING
962
961
963
- public override fun cancel (cause : Throwable ? ): Boolean = when (onCancelMode) {
962
+ public actual override fun cancel (cause : Throwable ? ): Boolean = when (onCancelMode) {
964
963
ON_CANCEL_MAKE_CANCELLED -> makeCancelled(cause)
965
964
ON_CANCEL_MAKE_CANCELLING -> makeCancelling(cause)
966
965
ON_CANCEL_MAKE_COMPLETING -> makeCompletingOnCancel(cause)
@@ -1045,7 +1044,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
1045
1044
* @throws IllegalStateException if job is already complete or completing
1046
1045
* @suppress **This is unstable API and it is subject to change.**
1047
1046
*/
1048
- internal fun makeCompletingOnce (proposedUpdate : Any? , mode : Int ): Boolean =
1047
+ internal actual fun makeCompletingOnce (proposedUpdate : Any? , mode : Int ): Boolean =
1049
1048
when (makeCompletingInternal(proposedUpdate, mode)) {
1050
1049
COMPLETING_COMPLETED -> true
1051
1050
COMPLETING_WAITING_CHILDREN -> false
@@ -1128,7 +1127,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
1128
1127
}
1129
1128
}
1130
1129
1131
- public final override val children: Sequence <Job > get() = buildSequence {
1130
+ public actual final override val children: Sequence <Job > get() = buildSequence {
1132
1131
val state = this @JobSupport.state
1133
1132
when (state) {
1134
1133
is Child -> yield (state.childJob)
@@ -1139,7 +1138,7 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
1139
1138
}
1140
1139
1141
1140
@Suppress(" OverridingDeprecatedMember" )
1142
- public final override fun attachChild (child : Job ): DisposableHandle =
1141
+ public actual final override fun attachChild (child : Job ): DisposableHandle =
1143
1142
invokeOnCompletion(onCancelling = true , handler = Child (this , child))
1144
1143
1145
1144
@Suppress(" OverridingDeprecatedMember" )
@@ -1150,8 +1149,9 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
1150
1149
/* *
1151
1150
* Override to process any exceptions that were encountered while invoking completion handlers
1152
1151
* installed via [invokeOnCompletion].
1152
+ * @suppress **This is unstable API and it is subject to change.**
1153
1153
*/
1154
- internal open fun handleException (exception : Throwable ) {
1154
+ internal actual open fun handleException (exception : Throwable ) {
1155
1155
throw exception
1156
1156
}
1157
1157
@@ -1162,23 +1162,23 @@ internal open class JobSupport(active: Boolean) : Job, SelectClause0 {
1162
1162
* null when it has completed normally.
1163
1163
* @suppress **This is unstable API and it is subject to change.**
1164
1164
*/
1165
- internal open fun onCancellationInternal (exceptionally : CompletedExceptionally ? ) {}
1165
+ internal actual open fun onCancellationInternal (exceptionally : CompletedExceptionally ? ) {}
1166
1166
1167
1167
/* *
1168
1168
* Override for post-completion actions that need to do something with the state.
1169
1169
* @param mode completion mode.
1170
1170
* @suppress **This is unstable API and it is subject to change.**
1171
1171
*/
1172
- internal open fun afterCompletion (state : Any? , mode : Int ) {}
1172
+ internal actual open fun afterCompletion (state : Any? , mode : Int ) {}
1173
1173
1174
1174
// for nicer debugging
1175
- override fun toString (): String =
1175
+ public override fun toString (): String =
1176
1176
" ${nameString()} {${stateString()} }@$hexAddress "
1177
1177
1178
1178
/* *
1179
1179
* @suppress **This is unstable API and it is subject to change.**
1180
1180
*/
1181
- internal open fun nameString (): String = this ::class .java.simpleName
1181
+ internal actual open fun nameString (): String = this ::class .java.simpleName
1182
1182
1183
1183
private fun stateString (): String {
1184
1184
val state = this .state
0 commit comments