-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
autoClose
for Resource
to common
- Loading branch information
Showing
15 changed files
with
127 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
arrow-libs/core/arrow-autoclose/src/jvmMain/kotlin/arrow/AutoCloseableExtensions.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,7 @@ final fun <#A: kotlin/Any?> (kotlinx.coroutines.flow/Flow<#A>).arrow.fx.coroutin | |
final fun <#A: kotlin/Any?> (kotlinx.coroutines.flow/Flow<#A>).arrow.fx.coroutines/repeat(): kotlinx.coroutines.flow/Flow<#A> // arrow.fx.coroutines/repeat|[email protected]<0:0>(){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.fx.coroutines/resource(kotlin.coroutines/SuspendFunction0<#A>, kotlin.coroutines/SuspendFunction2<#A, arrow.fx.coroutines/ExitCase, kotlin/Unit>): kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A> // arrow.fx.coroutines/resource|resource(kotlin.coroutines.SuspendFunction0<0:0>;kotlin.coroutines.SuspendFunction2<0:0,arrow.fx.coroutines.ExitCase,kotlin.Unit>){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/Any?> arrow.fx.coroutines/resource(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A>): kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A> // arrow.fx.coroutines/resource|resource(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ResourceScope,0:0>){0§<kotlin.Any?>}[0] | ||
final fun <#A: kotlin/AutoCloseable> arrow.fx.coroutines/autoCloseable(kotlinx.coroutines/CoroutineDispatcher = ..., kotlin.coroutines/SuspendFunction0<#A>): kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A> // arrow.fx.coroutines/autoCloseable|autoCloseable(kotlinx.coroutines.CoroutineDispatcher;kotlin.coroutines.SuspendFunction0<0:0>){0§<kotlin.AutoCloseable>}[0] | ||
final fun arrow.fx.coroutines/fixedRate(kotlin.time/Duration, kotlin/Boolean = ..., kotlin/Function0<kotlin.time/ComparableTimeMark> = ...): kotlinx.coroutines.flow/Flow<kotlin/Unit> // arrow.fx.coroutines/fixedRate|fixedRate(kotlin.time.Duration;kotlin.Boolean;kotlin.Function0<kotlin.time.ComparableTimeMark>){}[0] | ||
final fun arrow.fx.coroutines/fixedRate(kotlin/Long, kotlin/Boolean = ..., kotlin/Function0<kotlin.time/ComparableTimeMark> = ...): kotlinx.coroutines.flow/Flow<kotlin/Unit> // arrow.fx.coroutines/fixedRate|fixedRate(kotlin.Long;kotlin.Boolean;kotlin.Function0<kotlin.time.ComparableTimeMark>){}[0] | ||
final inline fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.coroutines.flow/Flow<#A>).arrow.fx.coroutines/mapIndexed(crossinline kotlin.coroutines/SuspendFunction2<kotlin/Int, #A, #B>): kotlinx.coroutines.flow/Flow<#B> // arrow.fx.coroutines/mapIndexed|[email protected]<0:0>(kotlin.coroutines.SuspendFunction2<kotlin.Int,0:0,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0] | ||
|
@@ -166,6 +167,7 @@ final suspend fun <#A: kotlin/Any?> (kotlin.coroutines/SuspendFunction1<arrow.fx | |
final suspend fun <#A: kotlin/Any?> (kotlinx.coroutines/CoroutineScope).arrow.fx.coroutines.await/awaitAll(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines.await/AwaitAllScope, #A>): #A // arrow.fx.coroutines.await/awaitAll|[email protected](kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.await.AwaitAllScope,0:0>){0§<kotlin.Any?>}[0] | ||
final suspend fun <#A: kotlin/Any?> arrow.fx.coroutines.await/awaitAll(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines.await/AwaitAllScope, #A>): #A // arrow.fx.coroutines.await/awaitAll|awaitAll(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.await.AwaitAllScope,0:0>){0§<kotlin.Any?>}[0] | ||
final suspend fun <#A: kotlin/Any?> arrow.fx.coroutines/resourceScope(kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ResourceScope, #A>): #A // arrow.fx.coroutines/resourceScope|resourceScope(kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ResourceScope,0:0>){0§<kotlin.Any?>}[0] | ||
final suspend fun <#A: kotlin/AutoCloseable> (arrow.fx.coroutines/ResourceScope).arrow.fx.coroutines/autoCloseable(kotlinx.coroutines/CoroutineDispatcher = ..., kotlin.coroutines/SuspendFunction0<#A>): #A // arrow.fx.coroutines/autoCloseable|[email protected](kotlinx.coroutines.CoroutineDispatcher;kotlin.coroutines.SuspendFunction0<0:0>){0§<kotlin.AutoCloseable>}[0] | ||
final suspend fun arrow.fx.coroutines/cancelAndCompose(kotlinx.coroutines/Deferred<*>, kotlinx.coroutines/Deferred<*>) // arrow.fx.coroutines/cancelAndCompose|cancelAndCompose(kotlinx.coroutines.Deferred<*>;kotlinx.coroutines.Deferred<*>){}[0] | ||
final suspend inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?, #E: kotlin/Any?, #F: kotlin/Any?, #G: kotlin/Any?, #H: kotlin/Any?, #I: kotlin/Any?, #J: kotlin/Any?, #K: kotlin/Any?> (arrow.core.raise/Raise<#A>).arrow.fx.coroutines/parZipOrAccumulate(crossinline kotlin/Function2<#A, #A, #A>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #B>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #C>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #D>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #E>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #F>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #G>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #H>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #I>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #J>, crossinline kotlin.coroutines/SuspendFunction10<kotlinx.coroutines/CoroutineScope, #B, #C, #D, #E, #F, #G, #H, #I, #J, #K>): #K // arrow.fx.coroutines/parZipOrAccumulate|[email protected]<0:0>(kotlin.Function2<0:0,0:0,0:0>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:1>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:2>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:3>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:4>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:5>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:6>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:7>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:8>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:9>;kotlin.coroutines.SuspendFunction10<kotlinx.coroutines.CoroutineScope,0:1,0:2,0:3,0:4,0:5,0:6,0:7,0:8,0:9,0:10>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>;3§<kotlin.Any?>;4§<kotlin.Any?>;5§<kotlin.Any?>;6§<kotlin.Any?>;7§<kotlin.Any?>;8§<kotlin.Any?>;9§<kotlin.Any?>;10§<kotlin.Any?>}[0] | ||
final suspend inline fun <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotlin/Any?, #E: kotlin/Any?, #F: kotlin/Any?, #G: kotlin/Any?, #H: kotlin/Any?, #I: kotlin/Any?, #J: kotlin/Any?, #K: kotlin/Any?> (arrow.core.raise/Raise<#A>).arrow.fx.coroutines/parZipOrAccumulate(kotlin.coroutines/CoroutineContext, crossinline kotlin/Function2<#A, #A, #A>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #B>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #C>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #D>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #E>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #F>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #G>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #H>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #I>, crossinline kotlin.coroutines/SuspendFunction1<arrow.fx.coroutines/ScopedRaiseAccumulate<#A>, #J>, crossinline kotlin.coroutines/SuspendFunction10<kotlinx.coroutines/CoroutineScope, #B, #C, #D, #E, #F, #G, #H, #I, #J, #K>): #K // arrow.fx.coroutines/parZipOrAccumulate|[email protected]<0:0>(kotlin.coroutines.CoroutineContext;kotlin.Function2<0:0,0:0,0:0>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:1>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:2>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:3>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:4>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:5>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:6>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:7>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:8>;kotlin.coroutines.SuspendFunction1<arrow.fx.coroutines.ScopedRaiseAccumulate<0:0>,0:9>;kotlin.coroutines.SuspendFunction10<kotlinx.coroutines.CoroutineScope,0:1,0:2,0:3,0:4,0:5,0:6,0:7,0:8,0:9,0:10>){0§<kotlin.Any?>;1§<kotlin.Any?>;2§<kotlin.Any?>;3§<kotlin.Any?>;4§<kotlin.Any?>;5§<kotlin.Any?>;6§<kotlin.Any?>;7§<kotlin.Any?>;8§<kotlin.Any?>;9§<kotlin.Any?>;10§<kotlin.Any?>}[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ResourceAutoCloseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package arrow.fx.coroutines | ||
|
||
import arrow.atomic.AtomicBoolean | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.property.Arb | ||
import io.kotest.property.checkAll | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.Test | ||
|
||
class ResourceAutoCloseTest { | ||
|
||
class AutoCloseableTest : AutoCloseable { | ||
val didClose = AtomicBoolean(false) | ||
override fun close() = didClose.set(true) | ||
} | ||
|
||
@Test | ||
fun autoCloseableCloses() = runTest { | ||
val t = AutoCloseableTest() | ||
resourceScope { | ||
autoCloseable { t } | ||
} | ||
|
||
t.didClose.get() shouldBe true | ||
} | ||
|
||
@Test | ||
fun autoCloseableClosesOnError() = runTest { | ||
checkAll(10, Arb.throwable()) { throwable -> | ||
val t = AutoCloseableTest() | ||
|
||
shouldThrow<Exception> { | ||
resourceScope { | ||
autoCloseable { t } | ||
throw throwable | ||
} | ||
} shouldBe throwable | ||
|
||
t.didClose.get() shouldBe true | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...w-libs/fx/arrow-fx-coroutines/src/jsMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package arrow.fx.coroutines | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
internal actual val IODispatcher: CoroutineDispatcher = Dispatchers.Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.