@@ -640,7 +640,6 @@ internal open class JobSupport constructor(active: Boolean) : Job, SelectClause0
640
640
private fun tryMakeCancelling (expect : Incomplete , list : NodeList , cause : Throwable ? ): Boolean {
641
641
val cancelled = Cancelled (this , cause)
642
642
if (! _state .compareAndSet(expect, Finishing (list, cancelled, false ))) return false
643
- onFinishingInternal(cancelled)
644
643
onCancellationInternal(cancelled)
645
644
// Materialize cause
646
645
notifyCancellation(list, cancelled.cause)
@@ -679,10 +678,10 @@ internal open class JobSupport constructor(active: Boolean) : Job, SelectClause0
679
678
if (state is Finishing && state.completing)
680
679
return COMPLETING_ALREADY_COMPLETING
681
680
val child: ChildJob ? = firstChild(state) ? : // or else complete immediately w/o children
682
- when {
683
- state !is Finishing && hasOnFinishingHandler(proposedUpdate) -> null // unless it has onFinishing handler
684
- tryFinalizeState(state, proposedUpdate, mode) -> return COMPLETING_COMPLETED
685
- else -> return @loopOnState
681
+ if (tryFinalizeState(state, proposedUpdate, mode)) {
682
+ return COMPLETING_COMPLETED
683
+ } else {
684
+ return @loopOnState // retry
686
685
}
687
686
val list = state.list ? : // must promote to list to correctly operate on child lists
688
687
when (state) {
@@ -704,7 +703,6 @@ internal open class JobSupport constructor(active: Boolean) : Job, SelectClause0
704
703
val completing = Finishing (list, cancelled, true )
705
704
if (_state .compareAndSet(state, completing)) {
706
705
(state as ? Finishing )?.transferExceptions(completing)
707
- if (state !is Finishing ) onFinishingInternal(proposedUpdate)
708
706
if (child != null && tryWaitForChild(child, proposedUpdate))
709
707
return COMPLETING_WAITING_CHILDREN
710
708
if (tryFinalizeState(completing, proposedUpdate, mode = MODE_ATOMIC_DEFAULT ))
@@ -800,17 +798,6 @@ internal open class JobSupport constructor(active: Boolean) : Job, SelectClause0
800
798
// TODO rename to "onCancelling"
801
799
}
802
800
803
- /* *
804
- * Whether job has [onFinishingInternal] handler for given [update]
805
- * @suppress **This is unstable API and it is subject to change.**
806
- */
807
- internal open fun hasOnFinishingHandler (update : Any? ) = false
808
-
809
- /* *
810
- * @suppress **This is unstable API and it is subject to change.**
811
- */
812
- internal open fun onFinishingInternal (update : Any? ) {}
813
-
814
801
/* *
815
802
* Method which is invoked once Job becomes [Cancelled] or [CompletedExceptionally].
816
803
* It's guaranteed that at the moment of invocation the job and all its children are complete.
0 commit comments