Skip to content

Commit

Permalink
Make DisposableHandle fun interface, remove our own adapter (Kotlin#2790
Browse files Browse the repository at this point in the history
)
  • Loading branch information
qwwdfsad authored and pablobaxter committed Sep 14, 2022
1 parent 905b0cb commit 5ad4285
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
Expand Up @@ -367,7 +367,6 @@ public final class kotlinx/coroutines/Job$Key : kotlin/coroutines/CoroutineConte
}

public final class kotlinx/coroutines/JobKt {
public static final fun DisposableHandle (Lkotlin/jvm/functions/Function0;)Lkotlinx/coroutines/DisposableHandle;
public static final fun Job (Lkotlinx/coroutines/Job;)Lkotlinx/coroutines/CompletableJob;
public static final synthetic fun Job (Lkotlinx/coroutines/Job;)Lkotlinx/coroutines/Job;
public static synthetic fun Job$default (Lkotlinx/coroutines/Job;ILjava/lang/Object;)Lkotlinx/coroutines/CompletableJob;
Expand Down
14 changes: 1 addition & 13 deletions kotlinx-coroutines-core/common/src/Job.kt
Expand Up @@ -387,26 +387,14 @@ public fun Job0(parent: Job? = null): Job = Job(parent)
/**
* A handle to an allocated object that can be disposed to make it eligible for garbage collection.
*/
public interface DisposableHandle {
public fun interface DisposableHandle {
/**
* Disposes the corresponding object, making it eligible for garbage collection.
* Repeated invocation of this function has no effect.
*/
public fun dispose()
}

/**
* @suppress **This an internal API and should not be used from general code.**
*/
@Suppress("FunctionName")
@InternalCoroutinesApi
public inline fun DisposableHandle(crossinline block: () -> Unit): DisposableHandle =
object : DisposableHandle {
override fun dispose() {
block()
}
}

// -------------------- Parent-child communication --------------------

/**
Expand Down

0 comments on commit 5ad4285

Please sign in to comment.