@@ -123,8 +123,7 @@ public suspend fun Job.join() {
123123 * This is an open class designed for extension by more specific classes that might augment the
124124 * state and mare store addition state information for completed jobs, like their result values.
125125 */
126- @Suppress(" LeakingThis" )
127- public open class JobSupport : AbstractCoroutineContextElement (Job ), Job {
126+ internal open class JobSupport : AbstractCoroutineContextElement (Job ), Job {
128127 /*
129128 === States ===
130129 name state class is Active?
@@ -176,7 +175,7 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
176175 * Initializes parent job.
177176 * It shall be invoked at most once after construction after all other initialization.
178177 */
179- public fun initParentJob (parent : Job ? ) {
178+ fun initParentJob (parent : Job ? ) {
180179 if (parent == null ) return
181180 check(registration == null )
182181 // directly pass HandlerNode to parent scope to optimize one closure object (see makeNode)
@@ -189,12 +188,12 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
189188 /* *
190189 * Returns current state of this job.
191190 */
192- internal fun getState (): Any? = state
191+ fun getState (): Any? = state
193192
194193 /* *
195194 * Tries to update current [state][getState] of this job.
196195 */
197- protected fun updateState (expect : Any , update : Any? ): Boolean {
196+ fun updateState (expect : Any , update : Any? ): Boolean {
198197 require(expect is Active && update !is Active ) // only active -> inactive transition is allowed
199198 if (! STATE .compareAndSet(this , expect, update)) return false
200199 // #1. Update linked state before invoking completion handlers
@@ -229,9 +228,9 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
229228 return true
230229 }
231230
232- public final override val isActive: Boolean get() = state is Active
231+ final override val isActive: Boolean get() = state is Active
233232
234- public final override fun onCompletion (handler : CompletionHandler ): Job .Registration {
233+ final override fun onCompletion (handler : CompletionHandler ): Job .Registration {
235234 var nodeCache: JobNode ? = null
236235 while (true ) { // lock-free loop on state
237236 val state = this .state
@@ -265,7 +264,7 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
265264 }
266265 }
267266
268- internal fun removeNode (node : JobNode ) {
267+ fun removeNode (node : JobNode ) {
269268 // remove logic depends on the state of the job
270269 while (true ) { // lock-free loop on job state
271270 val state = this .state
@@ -290,7 +289,7 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
290289 }
291290 }
292291
293- public final override fun cancel (reason : Throwable ? ): Boolean {
292+ final override fun cancel (reason : Throwable ? ): Boolean {
294293 while (true ) { // lock-free loop on state
295294 val state = this .state as ? Active ? : return false // quit if not active anymore
296295 if (updateState(state, Cancelled (reason))) return true
@@ -300,19 +299,19 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
300299 /* *
301300 * Override to make linked state changes before completion handlers are invoked.
302301 */
303- protected open fun onStateUpdate (update : Any? ) {}
302+ open fun onStateUpdate (update : Any? ) {}
304303
305304 /* *
306305 * Override to process any exceptions that were encountered while invoking [onCompletion] handlers.
307306 */
308- protected open fun handleCompletionException (closeException : Throwable ) {
307+ open fun handleCompletionException (closeException : Throwable ) {
309308 throw closeException
310309 }
311310
312311 /* *
313312 * Override for post-completion actions that need to do something with the state.
314313 */
315- protected open fun afterCompletion (state : Any? ) {}
314+ open fun afterCompletion (state : Any? ) {}
316315
317316 private fun makeNode (handler : CompletionHandler ): JobNode =
318317 (handler as ? JobNode )?.also { require(it.job == = this ) }
@@ -321,7 +320,7 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
321320 /* *
322321 * Marker interface for active [state][getState] of a job.
323322 */
324- public interface Active
323+ internal interface Active
325324
326325 private object Empty : Active
327326
@@ -330,15 +329,15 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
330329 /* *
331330 * Abstract class for a [state][getState] of a job that had completed exceptionally, including cancellation.
332331 */
333- public abstract class CompletedExceptionally {
332+ internal abstract class CompletedExceptionally {
334333 abstract val cancelReason: Throwable // original reason or fresh CancellationException
335334 abstract val exception: Throwable // the exception to be thrown in continuation
336335 }
337336
338337 /* *
339338 * Represents a [state][getState] of a cancelled job.
340339 */
341- public class Cancelled (specifiedReason : Throwable ? ) : CompletedExceptionally() {
340+ internal class Cancelled (specifiedReason : Throwable ? ) : CompletedExceptionally() {
342341 @Volatile
343342 private var _cancelReason = specifiedReason // materialize CancellationException on first need
344343
@@ -359,7 +358,7 @@ public open class JobSupport : AbstractCoroutineContextElement(Job), Job {
359358 /* *
360359 * Represents a [state][getState] of a failed job.
361360 */
362- public class Failed (override val exception : Throwable ) : CompletedExceptionally() {
361+ internal class Failed (override val exception : Throwable ) : CompletedExceptionally() {
363362 override val cancelReason: Throwable
364363 get() = exception
365364 }
0 commit comments