Skip to content

Commit

Permalink
Remove suspend modifier from ResourceScope.onRelease (#3522)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyay10 authored Nov 5, 2024
1 parent 129206f commit f0f4e74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,13 @@ public final class arrow/fx/coroutines/ResourceKt {
public abstract interface class arrow/fx/coroutines/ResourceScope : arrow/AutoCloseScope {
public abstract fun bind (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun install (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun onRelease (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun onRelease (Lkotlin/jvm/functions/Function2;)V
public abstract fun release (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun releaseCase (Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class arrow/fx/coroutines/ResourceScope$DefaultImpls {
public static fun install (Larrow/fx/coroutines/ResourceScope;Ljava/lang/AutoCloseable;)Ljava/lang/AutoCloseable;
public static fun onRelease (Larrow/fx/coroutines/ResourceScope;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun release (Larrow/fx/coroutines/ResourceScope;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun releaseCase (Larrow/fx/coroutines/ResourceScope;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ open annotation class arrow.fx.coroutines/ScopeDSL : kotlin/Annotation { // arro
}

abstract interface arrow.fx.coroutines/ResourceScope : arrow/AutoCloseScope { // arrow.fx.coroutines/ResourceScope|null[0]
abstract fun onRelease(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ExitCase, kotlin/Unit>) // arrow.fx.coroutines/ResourceScope.onRelease|onRelease(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ExitCase,kotlin.Unit>){}[0]
abstract suspend fun <#A1: kotlin/Any?> (kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A1>).bind(): #A1 // arrow.fx.coroutines/ResourceScope.bind|[email protected]<arrow.fx.coroutines.ResourceScope,0:0>(){0§<kotlin.Any?>}[0]
abstract suspend fun <#A1: kotlin/Any?> install(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/AcquireStep, #A1>, kotlin.coroutines/SuspendFunction2<#A1, arrow.fx.coroutines/ExitCase, kotlin/Unit>): #A1 // arrow.fx.coroutines/ResourceScope.install|install(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.AcquireStep,0:0>;kotlin.coroutines.SuspendFunction2<0:0,arrow.fx.coroutines.ExitCase,kotlin.Unit>){0§<kotlin.Any?>}[0]
open suspend fun <#A1: kotlin/Any?> (kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A1>).release(kotlin.coroutines/SuspendFunction1<#A1, kotlin/Unit>): #A1 // arrow.fx.coroutines/ResourceScope.release|[email protected]<arrow.fx.coroutines.ResourceScope,0:0>(kotlin.coroutines.SuspendFunction1<0:0,kotlin.Unit>){0§<kotlin.Any?>}[0]
open suspend fun <#A1: kotlin/Any?> (kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A1>).releaseCase(kotlin.coroutines/SuspendFunction2<#A1, arrow.fx.coroutines/ExitCase, kotlin/Unit>): #A1 // arrow.fx.coroutines/ResourceScope.releaseCase|[email protected]<arrow.fx.coroutines.ResourceScope,0:0>(kotlin.coroutines.SuspendFunction2<0:0,arrow.fx.coroutines.ExitCase,kotlin.Unit>){0§<kotlin.Any?>}[0]
open suspend fun onRelease(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ExitCase, kotlin/Unit>) // arrow.fx.coroutines/ResourceScope.onRelease|onRelease(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ExitCase,kotlin.Unit>){}[0]
}

final class <#A: kotlin/Any?> arrow.fx.coroutines/ScopedRaiseAccumulate : arrow.core.raise/RaiseAccumulate<#A>, kotlinx.coroutines/CoroutineScope { // arrow.fx.coroutines/ScopedRaiseAccumulate|null[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ public interface ResourceScope : AutoCloseScope {
return install({ a }, release)
}

public suspend infix fun onRelease(release: suspend (ExitCase) -> Unit): Unit =
install({ }) { _, exitCase -> release(exitCase) }
public infix fun onRelease(release: suspend (ExitCase) -> Unit)
}

@ScopeDSL
Expand Down Expand Up @@ -491,7 +490,11 @@ private value class ResourceScopeImpl(
private val finalizers: Atomic<List<suspend (ExitCase) -> Unit>> = Atomic(emptyList()),
) : ResourceScope {
override suspend fun <A> Resource<A>.bind(): A = invoke(this@ResourceScopeImpl)


override fun onRelease(release: suspend (ExitCase) -> Unit) {
finalizers.update(release::prependTo)
}

override suspend fun <A> install(acquire: suspend AcquireStep.() -> A, release: suspend (A, ExitCase) -> Unit): A =
bracketCase({
val a = acquire(AcquireStep)
Expand Down

0 comments on commit f0f4e74

Please sign in to comment.