@@ -368,23 +368,29 @@ public open class JobSupport(active: Boolean) : AbstractCoroutineContextElement(
368
368
}
369
369
370
370
/* *
371
- * Tries to update current [state] of this job.
371
+ * Updates current [state] of this job.
372
372
*/
373
- internal fun updateState (expect : Any , update : Any? , mode : Int ): Boolean {
373
+ protected fun updateState (expect : Any , update : Any? , mode : Int ): Boolean {
374
374
if (! tryUpdateState(expect, update)) return false
375
375
completeUpdateState(expect, update, mode)
376
376
return true
377
377
}
378
378
379
- internal fun tryUpdateState (expect : Any , update : Any? ): Boolean {
379
+ /* *
380
+ * Tries to initiate update of the current [state] of this job.
381
+ */
382
+ protected fun tryUpdateState (expect : Any , update : Any? ): Boolean {
380
383
require(expect is Incomplete && update !is Incomplete ) // only incomplete -> completed transition is allowed
381
384
if (! STATE .compareAndSet(this , expect, update)) return false
382
385
// Unregister from parent job
383
386
parentHandle?.dispose() // volatile read parentHandle _after_ state was updated
384
387
return true // continues in completeUpdateState
385
388
}
386
389
387
- internal fun completeUpdateState (expect : Any , update : Any? , mode : Int ) {
390
+ /* *
391
+ * Completes update of the current [state] of this job.
392
+ */
393
+ protected fun completeUpdateState (expect : Any , update : Any? , mode : Int ) {
388
394
// Invoke completion handlers
389
395
val cause = (update as ? CompletedExceptionally )?.cause
390
396
var completionException: Throwable ? = null
0 commit comments