From b33123863cd0e2aeb29ef71b189cc43591e42693 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Mena Date: Tue, 28 May 2024 12:12:36 +0200 Subject: [PATCH] Rename to AwaitAllScope --- .../await/{AwaitScope.kt => AwaitAllScope.kt} | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) rename arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/{AwaitScope.kt => AwaitAllScope.kt} (79%) diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitScope.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitAllScope.kt similarity index 79% rename from arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitScope.kt rename to arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitAllScope.kt index 0cc7e75aac..3c20c5500a 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitScope.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/await/AwaitAllScope.kt @@ -6,21 +6,21 @@ import kotlinx.coroutines.async as coroutinesAsync import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Deferred -import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.awaitAll as coroutinesAwaitAll import kotlinx.coroutines.coroutineScope import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -public suspend fun await( - block: suspend AwaitScope.() -> A -): A = coroutineScope { block(AwaitScope(this)) } +public suspend fun awaitAll( + block: suspend AwaitAllScope.() -> A +): A = coroutineScope { block(AwaitAllScope(this)) } -public suspend fun CoroutineScope.await( - block: suspend AwaitScope.() -> A -): A = block(AwaitScope(this)) +public suspend fun CoroutineScope.awaitAll( + block: suspend AwaitAllScope.() -> A +): A = block(AwaitAllScope(this)) /** - * Within an [AwaitScope], any call to [kotlinx.coroutines.Deferred.await] + * Within an [AwaitAllScope], any call to [kotlinx.coroutines.Deferred.await] * causes all the other [Deferred] in the same block to be awaited too. * That way you can get more concurrency without having to sacrifice * readability. @@ -46,7 +46,7 @@ public suspend fun CoroutineScope.await( * } * ``` */ -public class AwaitScope( +public class AwaitAllScope( private val scope: CoroutineScope ): CoroutineScope by scope { private val tasks: Atomic>> = Atomic(emptyList()) @@ -65,7 +65,7 @@ public class AwaitScope( private val deferred: Deferred ): Deferred by deferred { override suspend fun await(): T { - tasks.getAndSet(emptyList()).awaitAll() + tasks.getAndSet(emptyList()).coroutinesAwaitAll() return deferred.await() } }