Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt AutoCloseable from standard library for CloseableCoroutineDispa… #4123

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public final class kotlinx/coroutines/ExceptionsKt {
public static final fun CancellationException (Ljava/lang/String;Ljava/lang/Throwable;)Ljava/util/concurrent/CancellationException;
}

public abstract class kotlinx/coroutines/ExecutorCoroutineDispatcher : kotlinx/coroutines/CoroutineDispatcher, java/io/Closeable {
public abstract class kotlinx/coroutines/ExecutorCoroutineDispatcher : kotlinx/coroutines/CoroutineDispatcher, java/io/Closeable, java/lang/AutoCloseable {
public static final field Key Lkotlinx/coroutines/ExecutorCoroutineDispatcher$Key;
public fun <init> ()V
public abstract fun close ()V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class <#A: kotlin/Any?> kotlinx.coroutines.flow/AbstractFlow : kotlinx.
constructor <init>() // kotlinx.coroutines.flow/AbstractFlow.<init>|<init>(){}[0]
final suspend fun collect(kotlinx.coroutines.flow/FlowCollector<#A>) // kotlinx.coroutines.flow/AbstractFlow.collect|collect(kotlinx.coroutines.flow.FlowCollector<1:0>){}[0]
}
abstract class kotlinx.coroutines/CloseableCoroutineDispatcher : kotlinx.coroutines/CoroutineDispatcher { // kotlinx.coroutines/CloseableCoroutineDispatcher|null[0]
abstract class kotlinx.coroutines/CloseableCoroutineDispatcher : kotlin/AutoCloseable, kotlinx.coroutines/CoroutineDispatcher { // kotlinx.coroutines/CloseableCoroutineDispatcher|null[0]
abstract fun close() // kotlinx.coroutines/CloseableCoroutineDispatcher.close|close(){}[0]
constructor <init>() // kotlinx.coroutines/CloseableCoroutineDispatcher.<init>|<init>(){}[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package kotlinx.coroutines
* might be added to this interface in the future, but is stable for use.
*/
@ExperimentalCoroutinesApi
public expect abstract class CloseableCoroutineDispatcher() : CoroutineDispatcher {
public expect abstract class CloseableCoroutineDispatcher() : CoroutineDispatcher, AutoCloseable {

/**
* Initiate the closing sequence of the coroutine dispatcher.
Expand All @@ -20,5 +20,5 @@ public expect abstract class CloseableCoroutineDispatcher() : CoroutineDispatche
*
* Invocations of `close` are idempotent and thread-safe.
*/
public abstract fun close()
public abstract override fun close()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package kotlinx.coroutines

public actual abstract class CloseableCoroutineDispatcher actual constructor() : CoroutineDispatcher() {
public actual abstract fun close()
public actual abstract class CloseableCoroutineDispatcher actual constructor() : CoroutineDispatcher(), AutoCloseable {
public actual abstract override fun close()
}
5 changes: 3 additions & 2 deletions kotlinx-coroutines-core/jvm/src/Executors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package kotlinx.coroutines

import kotlinx.coroutines.flow.*
import kotlinx.coroutines.internal.*
import java.io.*
import java.io.Closeable
import java.util.concurrent.*
import kotlin.coroutines.*
import kotlin.AutoCloseable

/**
* [CoroutineDispatcher] that has underlying [Executor] for dispatching tasks.
Expand All @@ -13,7 +14,7 @@ import kotlin.coroutines.*
* This class is generally used as a bridge between coroutine-based API and
* asynchronous API that requires an instance of the [Executor].
*/
public abstract class ExecutorCoroutineDispatcher: CoroutineDispatcher(), Closeable {
public abstract class ExecutorCoroutineDispatcher : CoroutineDispatcher(), Closeable, AutoCloseable {
/** @suppress */
@ExperimentalStdlibApi
public companion object Key : AbstractCoroutineContextKey<CoroutineDispatcher, ExecutorCoroutineDispatcher>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package kotlinx.coroutines

public actual abstract class CloseableCoroutineDispatcher actual constructor() : CoroutineDispatcher() {
public actual abstract fun close()
public actual abstract class CloseableCoroutineDispatcher actual constructor() : CoroutineDispatcher(), AutoCloseable {
public actual abstract override fun close()
}